Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- names="etc opt-etc cron"
- sshbin=/usr/bin/ssh
- gitbin=/usr/bin/git
- DEBUG=3
- debug() {
- level=$1
- msg=$2
- if [ $level -ge $DEBUG ]; then echo $msg; fi
- }
- for name in $names
- do
- if [ "$name" == "etc" ]; then path=/etc; fi
- if [ "$name" == "opt-etc" ]; then path=/opt/etc; fi
- if [ "$name" == "cron" ]; then path=/var/spool/cron; fi
- cd $path
- if [ ! -d $path ]; then debug 3 "$path doesn't exist"; continue; else debug 3 "cd $path"; fi
- cmd="$gitbin diff $name/master"
- debug 3 "about to execute $cmd"
- out=`$cmd`
- if [ $? -gt 0 ]; then
- if [ ! -e .gitignore ]; then echo "!.gitignore" >> .gitignore; fi
- debug 3 $out
- continue
- fi
- date=`date +'%Y-%m-%d %H:%M:%S'`
- cmd="( $gitbin add . ) && ( $gitbin commit -a -m '$date' )"
- debug 3 "about to execute $cmd"
- out=$($cmd)
- debug 3 $out
- cmd="$gitbin push $name master"
- debug 3 "about to execute $cmd"
- out=`$cmd`
- debug 3 $out
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement