Update scripts
This commit is contained in:
@@ -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
|
! 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")
|
#name=$(cut -d' ' -f1 <<< "$info")
|
||||||
fstype=$(cut -d' ' -f2 <<< "$info")
|
#fstype=$(cut -d' ' -f2 <<< "$info")
|
||||||
label=$(cut -d' ' -f3 <<< "$info")
|
label=$(cut -d' ' -f3 <<< "$info")
|
||||||
uuid=$(cut -d' ' -f4 <<< "$info")
|
#uuid=$(cut -d' ' -f4 <<< "$info")
|
||||||
mountedpoint=$(cut -d' ' -f5 <<< "$info")
|
mountedpoint=$(cut -d' ' -f5 <<< "$info")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
# Generic btrfsmaintenance install script
|
# Generic btrfsmaintenance install script
|
||||||
# Copyright 2021 Bryan C. Roessler
|
# Copyright 2021 Bryan C. Roessler
|
||||||
|
|
||||||
|
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
|
is_root
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ fi
|
|||||||
|
|
||||||
ask_ok "Create user $user with password $password?" || exit $?
|
ask_ok "Create user $user with password $password?" || exit $?
|
||||||
|
|
||||||
restore="no"
|
restore=0
|
||||||
if [[ -d /mnt/array/home-retired/$user ]]; then
|
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
|
fi
|
||||||
|
|
||||||
samba="no"
|
samba=0
|
||||||
ask_ok "Enable shared file access for user $user?" && group_str="smbgrp," && samba="yes"
|
ask_ok "Enable shared file access for user $user?" && group_str="smbgrp," && samba=1
|
||||||
|
|
||||||
ask_ok "Make $user an admin?" && \
|
ask_ok "Make $user an admin?" && \
|
||||||
group_str+="wheel"
|
group_str+="wheel"
|
||||||
@@ -48,7 +48,7 @@ ask_ok "Make $user an admin?" && \
|
|||||||
useradd_cmd+=("-G" "$group_str")
|
useradd_cmd+=("-G" "$group_str")
|
||||||
useradd_cmd+=("$user")
|
useradd_cmd+=("$user")
|
||||||
|
|
||||||
if [[ "$restore" == "yes" ]]; then
|
if (( restore )); then
|
||||||
if rsync -av --progress=info2 /mnt/array/home-retired/"$user" /home/"$user"; 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?" && \
|
ask_ok "User $user's files successfully restored, remove backup at /mnt/array/home-retired/$user?" && \
|
||||||
rm -rf /mnt/array/home-retired/"$user"
|
rm -rf /mnt/array/home-retired/"$user"
|
||||||
@@ -60,12 +60,12 @@ fi
|
|||||||
echo "$user":"$password" | chpasswd
|
echo "$user":"$password" | chpasswd
|
||||||
|
|
||||||
|
|
||||||
if [[ "$samba" == "yes" ]]; then
|
if (( samba )); then
|
||||||
(echo "$password"; echo "$password") | smbpasswd -a -s "$user"
|
(echo "$password"; echo "$password") | smbpasswd -a -s "$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ask_ok "Prompt user to reset password on next login?" &&
|
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
|
# TODO check if centos 9 does by default
|
||||||
# Add subuids & subgids for container namespace
|
# Add subuids & subgids for container namespace
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ is_root
|
|||||||
|
|
||||||
echo "This script supports one optional argument, a username"
|
echo "This script supports one optional argument, a username"
|
||||||
|
|
||||||
|
user_list=()
|
||||||
if [[ $# -eq 1 ]]; then
|
if [[ $# -eq 1 ]]; then
|
||||||
|
if [[ $1 == '--all' ]]; then
|
||||||
user="$1"
|
user="$1"
|
||||||
else
|
else
|
||||||
prompt user
|
prompt user
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
# Place in /usr/share/smartmontools/smartd_warning.d/ or use "DEVICESCAN -m @smartd-notify-all" in /etc/smartd.conf
|
# Place in /usr/share/smartmontools/smartd_warning.d/ or use "DEVICESCAN -m @smartd-notify-all" in /etc/smartd.conf
|
||||||
# Copyright 2021 Bryan C. Roessler
|
# Copyright 2021 Bryan C. Roessler
|
||||||
|
|
||||||
|
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
|
is_root
|
||||||
|
|||||||
Reference in New Issue
Block a user