diff --git a/cesnet-mcc/deploy.sh b/cesnet-mcc/deploy.sh index d051d3db500d634b87477fd9d339f8088dcd3bb6..905af9638d276340b63300a1e4cb8a49dca166e7 100755 --- a/cesnet-mcc/deploy.sh +++ b/cesnet-mcc/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-cesnet.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" shellstate=$(shopt -po xtrace) set +o xtrace # https://nsupdate.fedcloud.eu @@ -24,11 +24,11 @@ echo "Terraform finished. Continue? (CTRL-C to quit)" read -r _ # wait for ping and ssh -for ip in $(cat terraform/hosts.txt); do +while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done -done +done <terraform/hosts.txt # check ssh access ansible -m command -a 'uname -a' allnodes diff --git a/common/playbooks/files/usr/local/bin/k8s-pods-cleaner.sh b/common/playbooks/files/usr/local/bin/k8s-pods-cleaner.sh index 62859331b79ca7d99bf4319337ae63c5c8e3749f..007fc6e2304a79cb12af74b65ca583de928910df 100755 --- a/common/playbooks/files/usr/local/bin/k8s-pods-cleaner.sh +++ b/common/playbooks/files/usr/local/bin/k8s-pods-cleaner.sh @@ -17,7 +17,7 @@ NS="$1" PERFORM="$2" for pod in $(kubectl get pod -n "$NS" | awk 'NR>1 && $3=="Terminating" {print $1}'); do if [ -n "$PERFORM" ]; then - kubectl get pod -n "$NS" "$pod" -oyaml > "/tmp/$NS-$pod.yaml" + kubectl get pod -n "$NS" "$pod" -oyaml >"/tmp/$NS-$pod.yaml" kubectl delete pod -n "$NS" "$pod" --force else kubectl get pod -n "$NS" "$pod" diff --git a/common/playbooks/files/usr/local/bin/xfs-quotas.sh b/common/playbooks/files/usr/local/bin/xfs-quotas.sh index e0dd517719cbe5f361dc4d66917dc273ec5bc112..339f07f779edbc011b71cf5404581a00af4fd03d 100755 --- a/common/playbooks/files/usr/local/bin/xfs-quotas.sh +++ b/common/playbooks/files/usr/local/bin/xfs-quotas.sh @@ -29,7 +29,7 @@ DISK_MOUNTPOINT=/exports TARGET_PATH=/exports usage() { - cat << EOF + cat <<EOF $PROG [OPTIONS] OPTIONS are: -h,--help @@ -42,7 +42,6 @@ EOF return 0 } - TEMP=$(getopt -o 'i:e:s:q:hn' --long 'include:,exclude:,soft-quota:,hard-quota:,help,dry-run' -n 'xfs-quotas.sh' -- "$@") || exit $? eval set -- "$TEMP" unset TEMP @@ -53,45 +52,45 @@ hard="$HARD" truncate -s 0 /tmp/quota.list while true; do case "$1" in - -h|--help) - usage - shift - exit 0 - ;; - -s|--soft-quota) - soft="$2" - shift 2 - continue - ;; - -q|--hard-quota) - hard="$2" - shift 2 - continue - ;; - -e|--exclude) - grep -v "$2" /tmp/quota.list > /tmp/quota.list2 - mv /tmp/quota.list2 /tmp/quota.list - shift 2 - continue - ;; - -i|--include) - find $TARGET_PATH -mindepth 1 -maxdepth 1 -type d | grep "$2" >> /tmp/quota.list - shift 2 - continue - ;; - -n|--dry-run) - dry_run=1 - shift - continue - ;; - --) - shift - break - ;; - *) - usage - exit 1 - ;; + -h | --help) + usage + shift + exit 0 + ;; + -s | --soft-quota) + soft="$2" + shift 2 + continue + ;; + -q | --hard-quota) + hard="$2" + shift 2 + continue + ;; + -e | --exclude) + grep -v "$2" /tmp/quota.list >/tmp/quota.list2 + mv /tmp/quota.list2 /tmp/quota.list + shift 2 + continue + ;; + -i | --include) + find $TARGET_PATH -mindepth 1 -maxdepth 1 -type d | grep "$2" >>/tmp/quota.list + shift 2 + continue + ;; + -n | --dry-run) + dry_run=1 + shift + continue + ;; + --) + shift + break + ;; + *) + usage + exit 1 + ;; esac done @@ -99,26 +98,35 @@ test -f /etc/projects || touch /etc/projects test -f /etc/projid || touch /etc/projid # all specified directories -sort /tmp/quota.list | uniq > /tmp/quota.list2 +sort /tmp/quota.list | uniq >/tmp/quota.list2 mv /tmp/quota.list2 /tmp/quota.list # directories with quota -cut -d: -f1 /etc/projid 2>/dev/null | sort | uniq > /tmp/quota.xfs.list +cut -d: -f1 /etc/projid 2>/dev/null | sort | uniq >/tmp/quota.xfs.list lastid=0 -lastid="$( (maxid=0; IFS=:; while read -r dir id; do if test "$id" -gt "$maxid"; then maxid="$id"; fi; done; echo "$maxid") < /etc/projid )" -cat <<EOF > /tmp/quota-cmd.sh +lastid="$( ( + maxid=0 + IFS=: + while read -r dir id; do + if test "$id" -gt "$maxid"; then + maxid="$id" + fi + done + echo "$maxid" +) </etc/projid)" +cat <<EOF >/tmp/quota-cmd.sh #! /bin/sh -e cp -p /etc/projects /etc/projects.new cp -p /etc/projid /etc/projid.new EOF diff /tmp/quota.list /tmp/quota.xfs.list | grep '^< ' | while read -r _ dir; do - lastid=$((lastid+1)) + lastid=$((lastid + 1)) id="$lastid" - cat <<EOF >> /tmp/quota-cmd.sh -echo "$id:$dir" >> /etc/projects.new -echo "$dir:$id" >> /etc/projid.new + cat <<EOF >>/tmp/quota-cmd.sh +echo "$id:$dir" >>/etc/projects.new +echo "$dir:$id" >>/etc/projid.new xfs_quota -x -D /etc/projects.new -P /etc/projid.new -c "project -s $dir" $DISK_MOUNTPOINT >/dev/null xfs_quota -x -D /etc/projects.new -P /etc/projid.new -c "limit -p bsoft=$soft bhard=$hard $dir" $DISK_MOUNTPOINT diff --git a/production1/deploy.sh b/production1/deploy.sh index b1d9f7eb75e9e6ac27919b07e235bd47520a57ac..51af556549f974e4658728b23d234c0f2ce3b6a3 100755 --- a/production1/deploy.sh +++ b/production1/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-psnc.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" # shellstate=$(shopt -po xtrace) # set +o xtrace # # https://nsupdate.fedcloud.eu @@ -24,11 +24,11 @@ echo "Terraform finished. Check terraform/docker-volume.sh. Continue? (CTRL-C to read -r _ # wait for ping and ssh -for ip in $(cat terraform/fip.txt); do +while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done -done +done <terraform/fip.txt # check ssh access ansible -m command -a 'uname -a' allnodes diff --git a/production2/deploy.sh b/production2/deploy.sh index 0ec26d47ee46254825d19d648ce48c8e10b46e19..24d38db619b7afc46889ae7a995447b96db5f838 100755 --- a/production2/deploy.sh +++ b/production2/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-safespring.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" # shellstate=$(shopt -po xtrace) # set +o xtrace # # https://nsupdate.fedcloud.eu @@ -24,11 +24,11 @@ echo "Terraform finished. Check terraform/docker-volume.sh. Continue? (CTRL-C to read -r _ # wait for ping and ssh -for ip in $(cat terraform/hosts.txt); do +while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done -done +done <terraform/hosts.txt # check ssh access ansible -m command -a 'uname -a' allnodes diff --git a/staging1/deploy.sh b/staging1/deploy.sh index d87a2ea78683a2c43ceb5e1dccd4f542794cada2..239854c26c4b8ba7d3cd199f7dad2092f533ea9d 100755 --- a/staging1/deploy.sh +++ b/staging1/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-psnc.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" # shellstate=$(shopt -po xtrace) # set +o xtrace # # https://nsupdate.fedcloud.eu @@ -24,11 +24,11 @@ echo "Terraform finished. Check terraform/docker-volume.sh. Continue? (CTRL-C to read -r _ # wait for ping and ssh -for ip in $(cat terraform/fip.txt); do +while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done -done +done <terraform/fip.txt # check ssh access ansible -m command -a 'uname -a' allnodes diff --git a/staging2/deploy.sh b/staging2/deploy.sh index 64c1ce256a0ed605ac293a95463e14b20de3f98d..26dea73924463ce23993f590e3c420318c3166df 100755 --- a/staging2/deploy.sh +++ b/staging2/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-safespring.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" # shellstate=$(shopt -po xtrace) # set +o xtrace # # https://nsupdate.fedcloud.eu @@ -24,11 +24,11 @@ echo "Terraform finished. Check terraform/docker-volume.sh. Continue? (CTRL-C to read -r _ # wait for ping and ssh -for ip in $(cat terraform/hosts.txt); do +while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done -done +done <terraform/hosts.txt # check ssh access ansible -m command -a 'uname -a' allnodes diff --git a/testing/deploy.sh b/testing/deploy.sh index c9e7a1e70b7f8d36b22f890655d6ff4797ae9b79..771a70145e330387259e73a1c23927c3eb388047 100755 --- a/testing/deploy.sh +++ b/testing/deploy.sh @@ -9,7 +9,7 @@ cd - cp -pv terraform/inventory.yaml inventory/1-cesnet.yaml # dynamic DNS -ip="$(head -n 1 < terraform/fip.txt)" +ip="$(head -n 1 <terraform/fip.txt)" shellstate=$(shopt -po xtrace) set +o xtrace # https://nsupdate.fedcloud.eu @@ -24,7 +24,7 @@ echo "Terraform finished. Check terraform/docker-volume.sh. Continue? (CTRL-C to read -r _ # wait for ping and ssh -for ip in $(cat terraform/hosts.txt) $(cat terraform/fip.txt); do +cat terraform/hosts.txt terraform/fip.txt | while read -r ip; do while ! ping -c 1 "$ip"; do sleep 5; done ssh-keygen -R "$ip" while ! ssh egi@"$ip" -o ConnectTimeout=10 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no :; do sleep 10; done