0

I'd like to check for git repositories with uncommited changes on shutdown and if there are such repositories - print them and give user ability to decide what to do - resume shutdown or abort it.

I've made a function that checks for uncommited repos. Here it is in case someone is interested

   

find_uncommited() {
        if [ -n "$1" ];then
            local root_path=$1
        else
            local root_path=$(pwd)
        fi
        eval local trash='~/.local/*'
        find $root_path -type d -not -path $trash -iname '.git' 2>/dev/null | \
            xargs -I {} $SHELL -c \
            'dir=$(dirname {});cd $dir;uncommited=$(git ls-files --modified --deleted --exclude-standard --others;git log @{push}.. 2>/dev/null);if [ -n "$uncommited" ];then echo $dir;fi'
    }

I know that I can put some script into rc0 and somehow named it in such way that it would be invoked before unmounting drives, but I don't think it can be interactive.

Then there's this answer

Which gaved me idea that I can some some service that would listen to dbus shutdown event from unity and ... And then what exactly? How to make this interactive for user? I can probably write python gui app for that, but maybe there is a simpler pure shell way?

0

Store script in /etc/init.d

Also try to use absolute paths for your command, while quoting the other variable as well.

Give Proper File Permission to Execute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.