From: Mike Frysinger Date: Sat, 1 Feb 2014 23:14:48 +0000 (-0500) Subject: gentoo-sync: add command line options X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=603039f00c4097c9957c0d1add746af1c49e86bb;p=home.git gentoo-sync: add command line options --- diff --git a/.bin/gentoo-sync b/.bin/gentoo-sync index f987673..11bd717 100755 --- a/.bin/gentoo-sync +++ b/.bin/gentoo-sync @@ -1,20 +1,70 @@ #!/bin/bash -[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : - -logdir="/var/log" -sync_log="${logdir}/rsync.log" -up_log="${logdir}/emerge-updates.log" - GS_SYNC=true GS_RSYNC=false GS_EUPDATEDB=true GS_FETCH=false GS_UPWORLD=true GS_LAYMAN=true +GS_DEBUG=false conf="/etc/gentoo-sync.conf" [[ -e ${conf} ]] && . "${conf}" +usage() { + cat <<-EOF + Usage: ${0##*/} [options] + + Options: + -h, --help + -a, --all, -na, --noall + -s, --sync, -ns, --nosync ${GS_SYNC} + -r, --rsync, -nr, --norsync ${GS_RSYNC} + -d, --database, -nd, --nodatabase ${GS_EUPDATEDB} + -f, --fetch, -nf, --nofetch ${GS_FETCH} + -w, --world, -nw, --noworld ${GS_UPWORLD} + -l, --layman, -nl, --nolayman ${GS_LAYMAN} + -x, --debug, -nx, --nodebug ${GS_DEBUG} + EOF + exit 0 +} + +s() { + local x val=$1 + shift + for x ; do + eval GS_${x}=${val}; + done +} +for x ; do + case ${x} in + -h|--help) usage;; + -a|--all) s true SYNC RSYNC EUPDATEDB FETCH UPWORLD LAYMAN DEBUG;; + -na|--noall) s false SYNC RSYNC EUPDATEDB FETCH UPWORLD LAYMAN DEBUG;; + -s|--sync) s true SYNC;; + -ns|--nosync) s false SYNC;; + -r|--rsync) s true RSYNC;; + -nr|--norsync) s false RSYNC;; + -d|--database) s true EUPDATEDB;; + -nd|--nodatabase) s false EUPDATEDB;; + -f|--fetch) s true FETCH;; + -nf|--nofetch) s false FETCH;; + -w|--world) s true UPWORLD;; + -nw|--noworld) s false UPWORLD;; + -l|--layman) s true LAYMAN;; + -nl|--nolayman) s false LAYMAN;; + -x|--debug) s true DEBUG;; + -nx|--nodebug) s false DEBUG;; + *) usage;; + esac +done + +[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : +${GS_DEBUG} && set -x + +logdir="/var/log" +sync_log="${logdir}/rsync.log" +up_log="${logdir}/emerge-updates.log" + export NOCOLOR=true (