diff --git a/hacking/aliZsync b/hacking/aliZsync index 67dc2e534..678397b4a 100755 --- a/hacking/aliZsync +++ b/hacking/aliZsync @@ -42,6 +42,8 @@ ProgName=$(basename $0) POOLNAME="${ALIZSYNC_POOL_NAME:-aliZsync}" POOLSIZE="${ALIZSYNC_POOL_SIZE:-100G}" +IMG_FILE_PATH="${ALIZSYNC_IMG_FILE_PATH:-$HOME/$POOLNAME.img}" + INVENTORY_FILE="${ALIZSYNC_INVENTORY:-/etc/o2.d/aliZsync_inventory}" TARGET_ROOT="${ALIZSYNC_TARGET_ROOT:-/opt/alizsw}" TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") @@ -70,12 +72,16 @@ sub_help(){ sync_host(){ HOST="$1" - $SYNC_CMD "$DATASET_BINARIES" "ssh://root@$HOST:alizsw/sw/slc7_x86-64" + $SYNC_CMD --sshIdentity "/root/.ssh/id_rsa_aliZsync" "$DATASET_BINARIES" "ssh://root@$HOST:alizsw/sw/slc7_x86-64" echo -e "\t\t$HOST\tbinaries synchronized" - $SYNC_CMD "$DATASET_MODULES" "ssh://root@$HOST:alizsw/sw/MODULES" + $SYNC_CMD --sshIdentity "/root/.ssh/id_rsa_aliZsync" "$DATASET_MODULES" "ssh://root@$HOST:alizsw/sw/MODULES" echo -e "\t\t$HOST\tmodules synchronized" } +sub_build() { + aliBuild build --defaults o2-dataflow "$1" --remote-store="https://s3.cern.ch/swift/v1/alibuild-repo" +} + sub_sync(){ echo "synchronizing tags" source "$SCRIPT_DIR/aliZsync-job_pool.sh" @@ -103,10 +109,32 @@ sub_init(){ exit 1 fi - echo "creating sparse file at $HOME/$POOLNAME.img with size $POOLSIZE" - truncate -s "$POOLSIZE" "$HOME/$POOLNAME.img" + SSH_KEYFILE="$HOME/.ssh/id_rsa_aliZsync" + if [ ! -f "$SSH_KEYFILE" ]; then + echo "creating ssh key file" + mkdir -p "$HOME/.ssh" + ssh-keygen -t rsa -b 4096 -C "aliZsync@`uname -n`" -f "$HOME/.ssh/id_rsa_aliZsync" -q -N "" + + echo -n "Enter password for user root on inventory machines:" + read -s password + echo + + echo "setting up passwordless authentication" + while read LINE; do + [[ $LINE =~ ^#.* ]] && continue + [[ $LINE =~ ^\[.* ]] && continue + + # We only get the first word from the inventory line + HOST=$(echo "$LINE" | awk '{ print $1}') + echo -e "\t$HOST" + sshpass -p "$password" ssh-copy-id -i /root/.ssh/id_rsa_aliZsync "root@$HOST" + done < "$INVENTORY_FILE" + fi + + echo "creating sparse file at $IMG_FILE_PATH with size $POOLSIZE" + truncate -s "$POOLSIZE" "$IMG_FILE_PATH" echo "creating ZFS pool" - sudo zpool create -m "$PWD" "$POOLNAME" "$HOME/$POOLNAME.img" + sudo zpool create -m "$PWD" "$POOLNAME" "$IMG_FILE_PATH" cd . # no need to import after create: sudo zpool import -d $HOME -a @@ -122,7 +150,8 @@ sub_init(){ } sub_mount(){ - sudo zpool import -d $HOME -a + IMG_DIR="$(basename "$(dirname "$IMG_FILE_PATH")")" + sudo zpool import -d "$IMG_DIR" -a } sub_tag(){ diff --git a/hacking/aliZsync-sync-zfs-snapshots.py b/hacking/aliZsync-sync-zfs-snapshots.py index cdfa7d54a..95782ec33 100755 --- a/hacking/aliZsync-sync-zfs-snapshots.py +++ b/hacking/aliZsync-sync-zfs-snapshots.py @@ -38,6 +38,10 @@ def getZFSCmdLine (self, args): if self.sshIdentity: cmdLine.extend (['-i', self.sshIdentity]) + # Disable StrictHostKeyChecking, as we run in a closed environment + # TODO: make it an option + cmdLine.extend (['-o', 'StrictHostKeyChecking=no']) + cmdLine.append (self.user + '@' + self.server) cmdLine.extend (args) diff --git a/hacking/alizsw b/hacking/alizsw index 94275173d..2f4d433bc 100755 --- a/hacking/alizsw +++ b/hacking/alizsw @@ -38,6 +38,9 @@ ProgName=$(basename $0) POOLNAME="${ALIZSW_POOL_NAME:-alizsw}" +POOLSIZE="${ALIZSW_POOL_SIZE:-100G}" +IMG_FILE_PATH="${ALIZSW_IMG_FILE_PATH:-$HOME/$POOLNAME.img}" + TARGET_DIR="${ALIZSW_TARGET_ROOT:-/opt/alizsw}" TAG_NAME="${2:-latest}" @@ -71,10 +74,11 @@ sub_init(){ exit 1 fi - echo "creating sparse file at $HOME/$POOLNAME.img" - truncate -s 100G $HOME/$POOLNAME.img + echo "creating sparse file at $IMG_FILE_PATH" + truncate -s "$POOLSIZE" "$IMG_FILE_PATH" echo "creating ZFS pool" - sudo zpool create -m $TARGET_DIR $POOLNAME $HOME/$POOLNAME.img + sudo mkdir -p "$TARGET_DIR" + sudo zpool create -m "$TARGET_DIR" "$POOLNAME" "$IMG_FILE_PATH" cd . @@ -92,7 +96,8 @@ sub_list(){ } sub_mount(){ - sudo zpool import -d $HOME -a + IMG_DIR="$(basename "$(dirname "$IMG_FILE_PATH")")" + sudo zpool import -d "$IMG_DIR" -a } subcommand=$1