Update scripts
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Common functions for the lab scripts
|
# Common functions for the lab scripts
|
||||||
# Copyright 2021 Bryan C. Roessler
|
# Copyright Bryan C. Roessler
|
||||||
|
|
||||||
# Don't run this script directly
|
# Don't run this script directly
|
||||||
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
|
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
|
||||||
@@ -18,3 +18,14 @@ is_root() {
|
|||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copy_manual() {
|
||||||
|
cat <<-EOF > "$1/manual.desktop"
|
||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=Hartman Lab Server Manual
|
||||||
|
Type=Link
|
||||||
|
URL=https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY
|
||||||
|
Icon=text-html
|
||||||
|
EOF
|
||||||
|
}
|
||||||
@@ -5,6 +5,9 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
|
reload=0
|
||||||
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || reload=1
|
||||||
|
|
||||||
sourcedir="/home/roessler/shared/hartmanlab"
|
sourcedir="/home/roessler/shared/hartmanlab"
|
||||||
original_dir="$PWD"
|
original_dir="$PWD"
|
||||||
|
|
||||||
@@ -12,13 +15,12 @@ if [[ "$original_dir" != "$sourcedir" ]]; then
|
|||||||
pushd "$sourcedir" || exit $?
|
pushd "$sourcedir" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f functions ]] && . functions || exit 1
|
(( reload )) && [[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
install -m 644 ./functions /usr/local/bin/
|
|
||||||
|
|
||||||
for script in script-*; do
|
for script in script-*; do
|
||||||
|
[[ $script == "script-functions" ]] && install -m 644 "$script" /usr/local/bin/
|
||||||
cp -u "$script" /usr/local/bin/
|
cp -u "$script" /usr/local/bin/
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -41,5 +43,4 @@ for homedir in /home/*; do
|
|||||||
Icon=text-html
|
Icon=text-html
|
||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
unset desktop
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ if (( samba )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ask_ok "Prompt user to reset password on next login?" &&
|
ask_ok "Prompt user to reset password on next login?" &&
|
||||||
passwd --expire "$user"
|
passwd --expire "$user" &&
|
||||||
|
echo "NOTE: The file sharing (smbpasswd) will not be changed"
|
||||||
|
|
||||||
# TODO check if centos 9 does by default
|
# TODO check if centos 9 does by default
|
||||||
# Add subuids & subgids for container namespace
|
# Add subuids & subgids for container namespace
|
||||||
@@ -79,8 +80,8 @@ passwd --expire "$user"
|
|||||||
# echo "$user:$start_gid:$id_num" >> /etc/subgid
|
# echo "$user:$start_gid:$id_num" >> /etc/subgid
|
||||||
|
|
||||||
# Copy manual to user desktop
|
# Copy manual to user desktop
|
||||||
mkdir -p /home/"$user"/Desktop/
|
desktop="/home/$user/Desktop"
|
||||||
ln -fs "$parent"/README.html /home/"$user"/Desktop/
|
[[ -d $desktop ]] || sudo -u "$user" mkdir -p "$desktop"
|
||||||
chown "$user":"$user" -R /home/"$user"/Desktop
|
copy_manual "$desktop"
|
||||||
|
|
||||||
exit $?
|
exit 0
|
||||||
Reference in New Issue
Block a user