diff --git a/script-drives-add b/script-drives-add index b2e921fb..ffb185f4 100644 --- a/script-drives-add +++ b/script-drives-add @@ -6,7 +6,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-drives-fix-btrfs-full b/script-drives-fix-btrfs-full index ddf04f75..348833f6 100755 --- a/script-drives-fix-btrfs-full +++ b/script-drives-fix-btrfs-full @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-files-permissions-reset b/script-files-permissions-reset index 7ba00484..475b4c08 100755 --- a/script-files-permissions-reset +++ b/script-files-permissions-reset @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-files-permissions-set b/script-files-permissions-set index df53cbee..01565d38 100755 --- a/script-files-permissions-set +++ b/script-files-permissions-set @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-install-btrfsmaintenance b/script-install-btrfsmaintenance index 2c93768a..17499962 100755 --- a/script-install-btrfsmaintenance +++ b/script-install-btrfsmaintenance @@ -2,7 +2,7 @@ # Generic btrfsmaintenance install script # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-install-reverse-proxy b/script-install-reverse-proxy index ec0dbdb9..66756e26 100644 --- a/script-install-reverse-proxy +++ b/script-install-reverse-proxy @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-system-scheduled-restart b/script-system-scheduled-restart index 7c8cc7fc..97e0587d 100755 --- a/script-system-scheduled-restart +++ b/script-system-scheduled-restart @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-system-update b/script-system-update index 211e7989..c108393c 100755 --- a/script-system-update +++ b/script-system-update @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-system-update-r b/script-system-update-r deleted file mode 100755 index a466fca4..00000000 --- a/script-system-update-r +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Update the R binaries and RStudio-R4 application menu entry -# $1: R version number, ex. '4.1.2' -# $2: RStudio version number, ex. '2021.09.1-372' -# Copyright 2021 Bryan C. Roessler - -parent="${BASH_SOURCE[0]}" -parent=${parent%/*} - -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 - -is_root - -if [[ $# -eq 2 ]]; then - re='^[0-9].[0-9].[0-9]$' - if [[ ! $1 =~ $re ]]; then - echo "Bad R version number" - exit 1 - fi - re='^[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9]-[0-9]+$' - if [[ ! $2 =~ $re ]]; then - echo "Bad RStudio version number" - exit 1 - fi -else - echo "You must provide exactly two arguments!" - echo "\$1: R version, ex. '4.1.2'" - echo "\$2: RStudio version, ex. '2021.09.1-372'" - exit 1 -fi - -ask_ok "Update R to version $1 and RStudio to version $2?" || exit - -if sudo dnf install -y "https://cdn.rstudio.com/r/centos-7/pkgs/R-${1}-1-1.x86_64.rpm" \ - "https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-${2}-x86_64.rpm" \ - "https://download1.rstudio.org/desktop/centos7/x86_64/rstudio-${2}-x86_64.rpm" && -desktop_file="/usr/share/applications/rstudio-R4.desktop" && -[[ -f "$desktop_file" ]] && sed -i "s|/opt/R/.*/bin/R|/opt/R/$1/bin/R|" "$desktop_file"; then - echo "Successfully updated R and RStudio" - exit 0 -else - echo "R and RStudio update failed!" - exit 1 -fi \ No newline at end of file diff --git a/script-user-add b/script-user-add index bbbc5e31..ec044e63 100755 --- a/script-user-add +++ b/script-user-add @@ -5,20 +5,20 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root echo "This script supports two optional arguments, a username and password" if [[ $# -eq 0 ]]; then - prompt username + prompt user prompt password elif [[ $# -eq 1 ]]; then - username="$1" + user="$1" prompt password elif [[ $# -eq 2 ]]; then - username="$1" + user="$1" password="$2" elif [[ $# -gt 2 ]]; then echo "Too many arguments provided" @@ -27,45 +27,45 @@ fi useradd_cmd=(useradd -m -U) -if id -u "$username" &>/dev/null; then - ask_ok "User $username exists. Run script-user-remove first?" || exit $? - "$parent"/script-user-remove "$username" || exit $? +if id -u "$user" &>/dev/null; then + ask_ok "User $user exists. Run script-user-remove first?" || exit $? + "$parent"/script-user-remove "$user" || exit $? fi -ask_ok "Create user $username with password $password?" || exit $? +ask_ok "Create user $user with password $password?" || exit $? restore="no" -if [[ -d /mnt/array/home-retired/$username ]]; then - ask_ok "Restore user $username's files from /mnt/array/home-retired/$user?" && restore="yes" +if [[ -d /mnt/array/home-retired/$user ]]; then + ask_ok "Restore user $user's files from /mnt/array/home-retired/$user?" && restore="yes" fi samba="no" -ask_ok "Enable shared file access for user $username?" && group_str="smbgrp," && samba="yes" +ask_ok "Enable shared file access for user $user?" && group_str="smbgrp," && samba="yes" -ask_ok "Make $username an admin?" && \ +ask_ok "Make $user an admin?" && \ group_str+="wheel" useradd_cmd+=("-G" "$group_str") -useradd_cmd+=("$username") +useradd_cmd+=("$user") if [[ "$restore" == "yes" ]]; then - if rsync -av --progress=info2 /mnt/array/home-retired/"$username" /home/"$username"; then - ask_ok "User $username's files successfully restored, remove backup at /mnt/array/home-retired/$username?" && \ - rm -rf /mnt/array/home-retired/"$username" + if rsync -av --progress=info2 /mnt/array/home-retired/"$user" /home/"$user"; then + ask_ok "User $user's files successfully restored, remove backup at /mnt/array/home-retired/$user?" && \ + rm -rf /mnt/array/home-retired/"$user" fi fi # echo "Running: ${useradd_cmd[*]}" "${useradd_cmd[@]}" -echo "$username":"$password" | chpasswd +echo "$user":"$password" | chpasswd if [[ "$samba" == "yes" ]]; then - (echo "$password"; echo "$password") | smbpasswd -a -s "$username" + (echo "$password"; echo "$password") | smbpasswd -a -s "$user" fi ask_ok "Prompt user to reset password on next login?" && -sudo passwd --expire "$username" +sudo passwd --expire "$user" # TODO check if centos 9 does by default # Add subuids & subgids for container namespace @@ -75,12 +75,12 @@ sudo passwd --expire "$username" # last_gid=$(tail -1 /etc/subgid | cut -d':' -f2) # start_uid=$(( last_uid + id_offset )) # start_gid=$(( last_gid + id_offset )) -# echo "$username:$start_uid:$id_num" >> /etc/subuid -# echo "$username:$start_gid:$id_num" >> /etc/subgid +# echo "$user:$start_uid:$id_num" >> /etc/subuid +# echo "$user:$start_gid:$id_num" >> /etc/subgid # Copy manual to user desktop -mkdir -p /home/"$username"/Desktop/ -ln -fs "$parent"/README.html /home/"$username"/Desktop/ -chown "$username":"$username" -R /home/"$username"/Desktop +mkdir -p /home/"$user"/Desktop/ +ln -fs "$parent"/README.html /home/"$user"/Desktop/ +chown "$user":"$user" -R /home/"$user"/Desktop exit $? diff --git a/script-user-register b/script-user-register deleted file mode 100644 index 5db4b74b..00000000 --- a/script-user-register +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# This script will register a new remote user for the lab workstation -# Copyright 2021 Bryan C. Roessler - -[[ $# -eq 0 ]] && remote_host="hartmanlab.genetics.uab.edu" - -[[ $# -eq 1 ]] && remote_host="$1" - -[[ $# -gt 1 ]] && echo "Only one argument permitted" && exit 1 - -#remote_host="hartmanlab.genetics.uab.edu" - -# generate local key if not available - -if [[ -x $(command -v ssh-copy-id) ]]; then - ask_ok "Copy public key to $remote_host?" - ssh-copy-id "$remote_host" -fi diff --git a/script-user-remove b/script-user-remove index 186316cf..ce5abb46 100755 --- a/script-user-remove +++ b/script-user-remove @@ -7,7 +7,7 @@ parent=${parent%/*} unset user -[[ -f $parent/functions ]] && . "$parent"/functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-user-reset-password b/script-user-reset-password index b6348970..8b335c3a 100755 --- a/script-user-reset-password +++ b/script-user-reset-password @@ -7,25 +7,27 @@ unset user password parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root +echo "This script supports two optional arguments, a username and password" + if [[ $# -eq 0 ]]; then - prompt username + prompt user prompt password elif [[ $# -eq 1 ]]; then - username="$1" + user="$1" prompt password elif [[ $# -eq 2 ]]; then - username="$1" + user="$1" password="$2" elif [[ $# -gt 2 ]]; then echo "Too many arguments provided" exit 1 fi -if ! id -u "$username" &>/dev/null; then +if ! id -u "$user" &>/dev/null; then echo "User $user does not exist" exit 1 fi diff --git a/script-user-reset-x2go b/script-user-reset-x2go index 52945558..05ad5d71 100755 --- a/script-user-reset-x2go +++ b/script-user-reset-x2go @@ -5,13 +5,17 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root -[[ $# -lt 1 ]] && echo "No username provided!" && exit 1 -[[ $# -ge 1 ]] && user="$1" +echo "This script supports one optional argument, a username" +if [[ $# -eq 1 ]]; then + user="$1" +else + prompt user +fi # Clean local user cache rm -rf /home/"$user"/.x2go/C-"$user"-* diff --git a/script-user-unban b/script-user-unban index fc1dc956..40151721 100755 --- a/script-user-unban +++ b/script-user-unban @@ -5,7 +5,7 @@ parent="${BASH_SOURCE[0]}" parent=${parent%/*} -[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/smartd-notify-all b/smartd-notify-all index dc990733..21042006 100755 --- a/smartd-notify-all +++ b/smartd-notify-all @@ -3,7 +3,7 @@ # Place in /usr/share/smartmontools/smartd_warning.d/ or use "DEVICESCAN -m @smartd-notify-all" in /etc/smartd.conf # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root