diff options
author | Dan McGee <dan@archlinux.org> | 2009-09-14 01:19:59 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-09-14 01:19:59 +0200 |
commit | 0897913c0adf10a0a9ff4d8790842715e0e3b1b4 (patch) | |
tree | b93ec0754dbd687e60e3aa3cecec9cb1608b3996 | |
parent | 2afa1063284a25ae2691b2727c45238d15025a9a (diff) | |
download | dbscripts-0897913c0adf10a0a9ff4d8790842715e0e3b1b4.tar.gz dbscripts-0897913c0adf10a0a9ff4d8790842715e0e3b1b4.tar.xz |
Add new get_repos_for_host() function
And use it. This allows us to have server-specific behavior in our scripts
without further patching, and it also allows us to simplify some of our
scripts a fair amount.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rwxr-xr-x | cron-jobs/adjust-permissions | 50 | ||||
-rwxr-xr-x | cron-jobs/ftpdir-cleanup | 8 | ||||
-rw-r--r-- | db-functions | 7 |
3 files changed, 38 insertions, 27 deletions
diff --git a/cron-jobs/adjust-permissions b/cron-jobs/adjust-permissions index 6670a6f..91f2de7 100755 --- a/cron-jobs/adjust-permissions +++ b/cron-jobs/adjust-permissions @@ -1,36 +1,40 @@ -#!/bin/sh +#!/bin/bash if [ -f /tmp/.ftpmaint.lck ]; then - exit 0 + exit 0 fi /bin/touch /tmp/.ftpmaint.lck +. "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" + +get_dir_owner() { + case $1 in + core) + echo "ftp:ftp-arch" ;; + extra) + echo "ftp:ftp-extra" ;; + testing) + echo "ftp:ftp-extra" ;; + community) + echo "root:tusers" ;; + community-testing) + echo "root:tusers" ;; + esac +} + #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null cd /srv/ftp -if [ -d "core" ]; then - #This is unique to gerolde (main arch server) - /bin/chown -R ftp:ftp-arch core/os/any - /bin/chown -R ftp:ftp-arch core/os/i686 - /bin/chown -R ftp:ftp-arch core/os/x86_64 - /bin/chown -R ftp:ftp-extra {extra,testing}/os/any - /bin/chown -R ftp:ftp-extra {extra,testing}/os/i686 - /bin/chown -R ftp:ftp-extra {extra,testing}/os/x86_64 - for d in core extra testing; do - /bin/chmod -R g+w $d/os/any - /bin/chmod -R g+w $d/os/i686 - /bin/chmod -R g+w $d/os/x86_64 - done -else - /bin/chown -R root:tusers {community,community-testing}/os/any - /bin/chown -R root:tusers {community,community-testing}/os/i686 - /bin/chown -R root:tusers {community,community-testing}/os/x86_64 - /bin/chmod -R g+w {community,community-testing}/os/any - /bin/chmod -R g+w {community,community-testing}/os/i686 - /bin/chmod -R g+w {community,community-testing}/os/x86_64 -fi +for d in $(get_repos_for_host); do + owner="$(get_dir_owner $d)" + echo /bin/chown -R $owner $d/os/{any,i686,x86_64} + #/bin/chown -R $owner $d/os/{any,i686,x86_64} + echo /bin/chmod -R g+w $d/os/{any,i686,x86_64} + #/bin/chmod -R g+w $d/os/{any,i686,x86_64} +done /bin/chmod 555 /srv/ftp diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 04caf93..d66138c 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,6 +1,9 @@ #!/bin/bash -repos="core extra testing" +. "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" + +repos="$(get_repos_for_host)" LOCKFILE="/tmp/.ftpdircleanup.lock" @@ -27,9 +30,6 @@ trap ctrl_c 2 #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null -#Get our destination dir -. "$(dirname $0)/../db-functions" - for repo in $repos; do $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo $CLEANUP_DESTDIR done diff --git a/db-functions b/db-functions index 071fb85..f4f9ee9 100644 --- a/db-functions +++ b/db-functions @@ -102,5 +102,12 @@ check_pkg_arch () { #check_pkg_arch pkgfile arch fi } +get_repos_for_host() { + if [ "$(hostname)" = "sigurd" ]; then + echo "community community-testing" + else + echo "core extra testing" + fi +} # vim: set ts=4 sw=4 noet ft=sh: |