import tempfile
import time
-base="/srv/static.debian.org"
serialname = '.serial'
had_warnings = False
+conffile = '/etc/staticsync.conf'
+config={}
+
+with open(conffile) as f:
+ for line in f:
+ line = line.rstrip()
+ if not line or line.startswith("#"): continue
+ (name, value) = line.split("=")
+ config[name] = value
+
+for key in ('base'):
+ if not key in config:
+ raise Exception("Configuration element '%s' not found in config file %s", key, conffile)
+
allclients = set()
with open('/etc/static-clients.conf') as f:
for line in f:
stage2(pipes, status, 'abort', clients)
return False
- failedmirrorsfile = os.path.join(base, 'master', component + "-failedmirrors")
+ failedmirrorsfile = os.path.join(config['base'], 'master', component + "-failedmirrors")
if 'failed' in cnt:
log("WARNING: %d clients failed! Continuing anyway!"%(cnt['failed'],))
global had_warnings
clients = allclients - meta['extraignoreclients']
# setup
- basemaster = os.path.join(base, 'master')
+ basemaster = os.path.join(config['base'], 'master')
componentdir = os.path.join(basemaster, component)
cur = componentdir + '-current-push'
live = componentdir + '-current-live'
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
componentlist=/etc/static-components.conf
-base=/home/staticsync/static-master/master
+. /etc/staticsync.conf
+if ! [ -n "$masterbase" ]; then
+ echo >&2 "masterbase not configured!"
+ exit 1
+fi
set -e
set -u
-if [ "`id -u`" != "`stat -c %u "$base"`" ]; then
+if [ "`id -u`" != "`stat -c %u "$masterbase"`" ]; then
echo >&2 "You are probably running this as the wrong user."
exit 1
fi
echo >&2 "$0: Invalid component: $component (not found in $componentlist)";
exit 1
fi
-tgt="$base/$component"
+tgt="$masterbase/$component"
if ! [ -d "$tgt" ]; then
echo "$0: Creating $tgt for $component";
mkdir "$tgt"
echo "$0: Acquiring locks..."
lock 201 "$tgt" 1
-tmpdir_new="$(mktemp -d --tmpdir="$base" "${component}-updating.incoming-XXXXXX")"
-tmpdir_old="$(mktemp -d --tmpdir="$base" "${component}-updating.removing-XXXXXX")"
+tmpdir_new="$(mktemp -d --tmpdir="$masterbase" "${component}-updating.incoming-XXXXXX")"
+tmpdir_old="$(mktemp -d --tmpdir="$masterbase" "${component}-updating.removing-XXXXXX")"
trap "rm -rf '$tmpdir_new' '$tmpdir_old'" EXIT
chmod 0755 "$tmpdir_new"
set -u
+. /etc/staticsync.conf
+if ! [ -n "$base" ]; then
+ echo >&2 "base not configured!"
+ exit 1
+fi
+
awk -v host="$(hostname -f)" '
!/^ *(#|$)/ {
split($6,ignorehosts,",")
print $1, $2
}' /etc/static-components.conf |
while read master component ; do
- static-mirror-run --one-stage "/srv/static.debian.org/mirrors/$component" "$master:$component/-live-"
+ static-mirror-run --one-stage "$base/mirrors/$component" "$master:$component/-live-"
done
}
componentlist=/etc/static-components.conf
+. /etc/staticsync.conf
+if ! [ -n "$staticuser" ]; then
+ echo >&2 "staticuser not configured!"
+ exit 1
+fi
if [ "$#" = 1 ]; then
component="$1"
exit 1
fi
-if [ "`id -nu`" != "staticsync" ]; then
- sudo -u staticsync static-update-component "$@"
+if [ "`id -nu`" != "$staticuser" ]; then
+ sudo -u "$staticuser" static-update-component "$@"
else
ssh -o AddressFamily=inet -t -t -o ServerAliveInterval=300 -o PreferredAuthentications=publickey "$masterhost" static-master-update-component "$component"
fi
set -e
set -u
+. /etc/staticsync.conf
+if ! [ -n "$base" ]; then
+ echo >&2 "base not configured!"
+ exit 1
+fi
+BASEDIR="$base"
+
MYLOGNAME="`basename "$0"`[$$]"
-BASEDIR="/srv/static.debian.org"
COMPONENTLIST=/etc/static-components.conf
usage() {
rule => 'proto tcp mod state state (NEW) mod multiport destination-ports (6881:6999) @subchain \'static-bt\' { saddr ($HOST_STATIC_V6) ACCEPT; }',
notarule => true,
}
+
+ file { "/etc/staticsync.conf":
+ content => @("EOF"),
+ # This file is sourced by bash
+ # and parsed by python
+ # - empty lines and lines starting with a # are ignored.
+ # - other lines are key=value. No extra spaces anywhere. No quoting.
+ base=/srv/static.debian.org
+ masterbase=/home/staticsync/static-master/master
+ staticuser=staticsync
+ | EOF
+ }
}