Skip to content
Snippets Groups Projects
Commit f613e84c authored by František Dvořák's avatar František Dvořák
Browse files

Shell linting

parent 4289fa7a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment