From c8de0fbfa448ccac892ed5af30f2e442e8fa84d9 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sun, 30 Jun 2024 18:14:23 -0400 Subject: [PATCH] Update scripts --- script-drives-add | 6 +++--- script-install-btrfsmaintenance | 3 +++ script-user-add | 14 +++++++------- script-user-reset-x2go | 2 ++ smartd-notify-all | 3 +++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/script-drives-add b/script-drives-add index ffb185f4..af436330 100644 --- a/script-drives-add +++ b/script-drives-add @@ -22,10 +22,10 @@ unset drive mountpoint ! info=$(lsblk -n -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT "$drive" | tr -s ' ') && echo "Drive $drive does not exist" && exit 1 -name=$(cut -d' ' -f1 <<< "$info") -fstype=$(cut -d' ' -f2 <<< "$info") +#name=$(cut -d' ' -f1 <<< "$info") +#fstype=$(cut -d' ' -f2 <<< "$info") label=$(cut -d' ' -f3 <<< "$info") -uuid=$(cut -d' ' -f4 <<< "$info") +#uuid=$(cut -d' ' -f4 <<< "$info") mountedpoint=$(cut -d' ' -f5 <<< "$info") diff --git a/script-install-btrfsmaintenance b/script-install-btrfsmaintenance index 17499962..a1d59b7c 100755 --- a/script-install-btrfsmaintenance +++ b/script-install-btrfsmaintenance @@ -2,6 +2,9 @@ # Generic btrfsmaintenance install script # Copyright 2021 Bryan C. Roessler +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + [[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root diff --git a/script-user-add b/script-user-add index ec044e63..764062bd 100755 --- a/script-user-add +++ b/script-user-add @@ -34,13 +34,13 @@ fi ask_ok "Create user $user with password $password?" || exit $? -restore="no" +restore=0 if [[ -d /mnt/array/home-retired/$user ]]; then - ask_ok "Restore user $user's files from /mnt/array/home-retired/$user?" && restore="yes" + ask_ok "Restore user $user's files from /mnt/array/home-retired/$user?" && restore=1 fi -samba="no" -ask_ok "Enable shared file access for user $user?" && group_str="smbgrp," && samba="yes" +samba=0 +ask_ok "Enable shared file access for user $user?" && group_str="smbgrp," && samba=1 ask_ok "Make $user an admin?" && \ group_str+="wheel" @@ -48,7 +48,7 @@ ask_ok "Make $user an admin?" && \ useradd_cmd+=("-G" "$group_str") useradd_cmd+=("$user") -if [[ "$restore" == "yes" ]]; then +if (( restore )); then 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" @@ -60,12 +60,12 @@ fi echo "$user":"$password" | chpasswd -if [[ "$samba" == "yes" ]]; then +if (( samba )); then (echo "$password"; echo "$password") | smbpasswd -a -s "$user" fi ask_ok "Prompt user to reset password on next login?" && -sudo passwd --expire "$user" +passwd --expire "$user" # TODO check if centos 9 does by default # Add subuids & subgids for container namespace diff --git a/script-user-reset-x2go b/script-user-reset-x2go index 05ad5d71..71126317 100755 --- a/script-user-reset-x2go +++ b/script-user-reset-x2go @@ -11,7 +11,9 @@ is_root echo "This script supports one optional argument, a username" +user_list=() if [[ $# -eq 1 ]]; then + if [[ $1 == '--all' ]]; then user="$1" else prompt user diff --git a/smartd-notify-all b/smartd-notify-all index 21042006..f4ac0f9c 100755 --- a/smartd-notify-all +++ b/smartd-notify-all @@ -3,6 +3,9 @@ # Place in /usr/share/smartmontools/smartd_warning.d/ or use "DEVICESCAN -m @smartd-notify-all" in /etc/smartd.conf # Copyright 2021 Bryan C. Roessler +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + [[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1 is_root