scripts / postsysupgrade

#!/bin/bash

case $1 in
    kalu)
        $0 localepurge &
        $0 dliu &
        $0 pkgclip &
        
        declare -a services
        shift
        for pkg in $@; do
            case $pkg in
                alsa-utils)
                    services=(${services[@]} alsa)
                    ;;
                cronie)
                    services=(${services[@]} crond)
                    ;;
                mysql)
                    services=(${services[@]} mysqld)
                    ;;
                nginx | php-fpm | pdnsd | iptables | syslog-ng)
                    services=(${services[@]} $pkg)
                    ;;
            esac
        done
        
        if [[ ${#services[@]} > 0 ]]; then
            $0 restart ${services[@]}
        fi
        ;;
    
    localepurge)
        urxvt -geometry '90x15' -title localepurge -e bash -c \
            'sudo localepurge && echo Press ENTER to close && read' &
        ;;
    
    dliu)
        ret=2
        while [ $ret -eq 2 ]; do
            LIST=$(lsof +c 0 | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u)
            if [[ $LIST = "" ]]; then
                ic-info 'No deleted libraries in use found'
                exit 0
            fi
            echo "$LIST" | ic-text -e Refresh -E gtk-refresh -T 'Deleted Libraries In Use'
            ret=$?
        done
        ;;
    
    pkgclip)
        ic-question -T 'Start pkgclip ?' -b 'Yes, start pkgclip' \
            'Do you want to start pkgclip ?' && pkgclip &
        ;;
    
    restart)
        shift
        SERVICES=$(ic-list -MCHT 'Which services to restart?' \
            -i 'Which of the following upgraded services do you want to restart ?' \
            ${@})
        
        if [[ -z $SERVICES ]]; then
            exit 0
        fi
        
        CMD=
        LST="Services to be restarted: "
        for service in $SERVICES; do
            CMD="$CMD sudo /etc/rc.d/$service restart && "
            LST="$LST $service"
        done
        CMD="echo $LST && $CMD echo Press ENTER to close && read"
        
        urxvt -geometry '90x15' -title 'restarting services' -e bash -c "$CMD"
        ;;
    
    *)
        echo "syntax:"
        echo " ${0##*/} kalu [PACKAGE...]         to be called after sysupgrade, w/ upgraded packages"
        echo " ${0##*/} localepurge               start localepurge in a new terminal"
        echo " ${0##*/} dliu                      show Deleted Librairies In Use"
        echo " ${0##*/} pkgclip                   ask whether to start pkgclip"
        echo " ${0##*/} restart [SERVICE..]       ask to restart services"
        ;;
esac
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.