Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. names="etc opt-etc cron"
  4. sshbin=/usr/bin/ssh
  5. gitbin=/usr/bin/git
  6.  
  7. DEBUG=3
  8.  
  9. debug() {
  10.     level=$1
  11.     msg=$2
  12.     if [ $level -ge $DEBUG ]; then echo $msg; fi
  13. }
  14.  
  15.  
  16. for name in $names
  17.     do
  18.         if [ "$name" == "etc" ];     then path=/etc; fi
  19.         if [ "$name" == "opt-etc" ]; then path=/opt/etc; fi
  20.         if [ "$name" == "cron" ];    then path=/var/spool/cron; fi
  21.  
  22.         cd $path
  23.         if [ ! -d $path ]; then debug 3 "$path doesn't exist"; continue; else debug 3 "cd $path"; fi
  24.  
  25.         cmd="$gitbin diff $name/master"
  26.         debug 3 "about to execute $cmd"
  27.         out=`$cmd`
  28.  
  29.         if [ $? -gt 0 ]; then
  30.             if [ ! -e .gitignore ]; then echo "!.gitignore" >> .gitignore; fi
  31.             debug 3 $out
  32.             continue
  33.         fi
  34.  
  35.         date=`date +'%Y-%m-%d %H:%M:%S'`
  36.         cmd="( $gitbin add . ) && ( $gitbin commit -a -m '$date' )"
  37.  
  38.         debug 3 "about to execute $cmd"
  39.         out=$($cmd)
  40.         debug 3 $out
  41.  
  42.         cmd="$gitbin push $name master"
  43.         debug 3 "about to execute $cmd"
  44.         out=`$cmd`
  45.         debug 3 $out
  46.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement