Dev
This commit is contained in:
35
functions
35
functions
@@ -19,38 +19,3 @@ is_root() {
|
||||
[[ $user != "root" ]] && echo "Script must be run with sudo rights!" && exit 1
|
||||
}
|
||||
|
||||
|
||||
if ! type -t readarray >/dev/null; then
|
||||
readarray() {
|
||||
local cmd opt t v=MAPFILE
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-h|--help) echo "minimal substitute readarray for older bash"; exit; ;;
|
||||
-r) shift; opt="$opt -r"; ;;
|
||||
-t) shift; t=1; ;;
|
||||
-u)
|
||||
shift;
|
||||
if [ -n "$1" ]; then
|
||||
opt="$opt -u $1";
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$1" =~ ^[A-Za-z_]+$ ]]; then
|
||||
v="$1"
|
||||
shift
|
||||
else
|
||||
echo -en "${C_BOLD}${C_RED}Error: ${C_RESET}Unknown option: '$1'\n" 1>&2
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
cmd="read $opt"
|
||||
eval "$v=()"
|
||||
while IFS= eval "$cmd line"; do
|
||||
line=$(echo "$line" | sed -e "s#\([\"\`]\)#\\\\\1#g" )
|
||||
eval "${v}+=(\"$line\")"
|
||||
done
|
||||
}
|
||||
fi
|
||||
|
||||
0
script-drives-add
Executable file → Normal file
0
script-drives-add
Executable file → Normal file
4
script-install-motd
Normal file → Executable file
4
script-install-motd
Normal file → Executable file
@@ -184,7 +184,7 @@ green="\e[1;32m"
|
||||
red="\e[1;31m"
|
||||
undim="\e[0m"
|
||||
|
||||
services=("fail2ban" "firewalld" "nmb" "motion" "btrfs-balance.timer" "btrfs-scrub.timer" "smb" "backup.timer" "btrbk.timer" "fstrim.timer" "dnf-automatic.timer" "smartd")
|
||||
services=("fail2ban" "firewalld" "nmb" "motion" "btrfs-balance.timer" "btrfs-scrub.timer" "smb" "backup.timer" "btrbk.timer" "fstrim.timer" "dnf-automatic.timer" "smartd" "generate-motd.timer")
|
||||
# sort services
|
||||
IFS=$'\n' services=($(sort <<<"${services[*]}"))
|
||||
unset IFS
|
||||
@@ -294,7 +294,7 @@ generate-services() {
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/bash $installdir/generate-motd.sh
|
||||
ExecStart=$banner > /etc/motd
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
2
script-user-register
Executable file → Normal file
2
script-user-register
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# This script will register a new remote user for the lab workstioastn
|
||||
# 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"
|
||||
|
||||
@@ -16,17 +16,14 @@ is_root
|
||||
|
||||
id -u "$user" || echo "User $user does not exist" && exit 1
|
||||
|
||||
if [[ "$password" == "reset" ]]; then
|
||||
ask_ok "Reset user $user's password?" || return $?
|
||||
passwd --expire "$user"
|
||||
password="$user" # For samba
|
||||
else
|
||||
ask_ok "Change user $user's password to $password?" && \
|
||||
echo "$user":"$password" | chpasswd
|
||||
fi
|
||||
password="${password:$user}" # For samba
|
||||
|
||||
ask_ok "Change user $user's Samba ppassword to $password?" && \
|
||||
ask_ok "Change user $user's password to $password?"
|
||||
echo "$user":"$password" | chpasswd
|
||||
echo "Expiring user password"
|
||||
passwd --expire "$user"
|
||||
|
||||
ask_ok "Change user $user's Samba password to $password?" && \
|
||||
(echo "$password"; echo "$password") | smbpasswd -a -s "$user"
|
||||
|
||||
|
||||
exit $?
|
||||
|
||||
Reference in New Issue
Block a user