diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-06-01 20:59:05 -0600 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-06-05 20:01:05 -0600 |
commit | 0cf1f12e623aa27e96f5c2a6f749913197a1a525 (patch) | |
tree | 0daf795b1b32f0852c8de9f00da9a5831af42a7b /src/abslibre-tools/librerelease | |
parent | 8430aec80c4f528d9fb161c801e946d695611f3f (diff) |
librerelease: wrap the end bit in `function main {...}; main "$@"`
Diffstat (limited to 'src/abslibre-tools/librerelease')
-rwxr-xr-x | src/abslibre-tools/librerelease | 106 |
1 files changed, 55 insertions, 51 deletions
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease index 09f2119..38fa0ac 100755 --- a/src/abslibre-tools/librerelease +++ b/src/abslibre-tools/librerelease @@ -97,57 +97,61 @@ function clean { rm -f $@ } -if [ -w / ]; then - error "Run $0 as normal user" - exit 1 -fi - -while getopts 'hlcn' arg; do - case $arg in - h) usage; exit 0 ;; - l) list_packages; exit 0 ;; - c) clean; exit $? ;; - n) dryrun="--dry-run" ;; - esac -done - -[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" - -clean_non_packages -sign_packages - -# Make the permissions of the packages 644 otherwise the user will get access -# denied error when they try to download (rsync --no-perms doesn't seem to -# work). -find ${WORKDIR}/staging -type f -exec chmod 644 {} \; -find ${WORKDIR}/staging -type d -exec chmod 755 {} \; - -# Get the synced files -SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) - -msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) -msg "Uploading packages..." -rsync --recursive \ - ${dryrun} \ - --no-group \ - --no-perms \ - --copy-links \ - --hard-links \ - --partial \ - --prune-empty-dirs \ - --human-readable \ - --progress \ - -e "ssh " \ - ${WORKDIR}/staging \ - ${PARABOLAHOST}:${LIBREDESTDIR}/ || { - error "Sync failed, try again" - exit 1 -} +function main { + if [ -w / ]; then + error "Run $0 as normal user" + exit 1 + fi -msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" -clean ${SYNCED_FILES[@]} + while getopts 'hlcn' arg; do + case $arg in + h) usage; exit 0 ;; + l) list_packages; exit 0 ;; + c) clean; exit $? ;; + n) dryrun="--dry-run" ;; + esac + done -msg "Running db-update on repos" -ssh ${PARABOLAHOST} dbscripts/db-update + [[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" + + clean_non_packages + sign_packages + + # Make the permissions of the packages 644 otherwise the user will get access + # denied error when they try to download (rsync --no-perms doesn't seem to + # work). + find ${WORKDIR}/staging -type f -exec chmod 644 {} \; + find ${WORKDIR}/staging -type d -exec chmod 755 {} \; + + # Get the synced files + SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) + + msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) + msg "Uploading packages..." + rsync --recursive \ + ${dryrun} \ + --no-group \ + --no-perms \ + --copy-links \ + --hard-links \ + --partial \ + --prune-empty-dirs \ + --human-readable \ + --progress \ + -e "ssh " \ + ${WORKDIR}/staging \ + ${PARABOLAHOST}:${LIBREDESTDIR}/ || { + error "Sync failed, try again" + exit 1 + } + + msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" + clean ${SYNCED_FILES[@]} + + msg "Running db-update on repos" + ssh ${PARABOLAHOST} dbscripts/db-update + + exit 0 +} -exit 0 +main "$@" |