Standardize function import
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Generic btrfsmaintenance install script
|
# Generic btrfsmaintenance install script
|
||||||
# Copyright 2021 Bryan C. Roessler
|
# Copyright 2021 Bryan C. Roessler
|
||||||
|
|
||||||
[[ -f functions ]] && . functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -5,20 +5,20 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
echo "This script supports two optional arguments, a username and password"
|
echo "This script supports two optional arguments, a username and password"
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
prompt username
|
prompt user
|
||||||
prompt password
|
prompt password
|
||||||
elif [[ $# -eq 1 ]]; then
|
elif [[ $# -eq 1 ]]; then
|
||||||
username="$1"
|
user="$1"
|
||||||
prompt password
|
prompt password
|
||||||
elif [[ $# -eq 2 ]]; then
|
elif [[ $# -eq 2 ]]; then
|
||||||
username="$1"
|
user="$1"
|
||||||
password="$2"
|
password="$2"
|
||||||
elif [[ $# -gt 2 ]]; then
|
elif [[ $# -gt 2 ]]; then
|
||||||
echo "Too many arguments provided"
|
echo "Too many arguments provided"
|
||||||
@@ -27,45 +27,45 @@ fi
|
|||||||
|
|
||||||
useradd_cmd=(useradd -m -U)
|
useradd_cmd=(useradd -m -U)
|
||||||
|
|
||||||
if id -u "$username" &>/dev/null; then
|
if id -u "$user" &>/dev/null; then
|
||||||
ask_ok "User $username exists. Run script-user-remove first?" || exit $?
|
ask_ok "User $user exists. Run script-user-remove first?" || exit $?
|
||||||
"$parent"/script-user-remove "$username" || exit $?
|
"$parent"/script-user-remove "$user" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ask_ok "Create user $username with password $password?" || exit $?
|
ask_ok "Create user $user with password $password?" || exit $?
|
||||||
|
|
||||||
restore="no"
|
restore="no"
|
||||||
if [[ -d /mnt/array/home-retired/$username ]]; then
|
if [[ -d /mnt/array/home-retired/$user ]]; then
|
||||||
ask_ok "Restore user $username's files from /mnt/array/home-retired/$user?" && restore="yes"
|
ask_ok "Restore user $user's files from /mnt/array/home-retired/$user?" && restore="yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
samba="no"
|
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"
|
group_str+="wheel"
|
||||||
|
|
||||||
useradd_cmd+=("-G" "$group_str")
|
useradd_cmd+=("-G" "$group_str")
|
||||||
useradd_cmd+=("$username")
|
useradd_cmd+=("$user")
|
||||||
|
|
||||||
if [[ "$restore" == "yes" ]]; then
|
if [[ "$restore" == "yes" ]]; then
|
||||||
if rsync -av --progress=info2 /mnt/array/home-retired/"$username" /home/"$username"; then
|
if rsync -av --progress=info2 /mnt/array/home-retired/"$user" /home/"$user"; then
|
||||||
ask_ok "User $username's files successfully restored, remove backup at /mnt/array/home-retired/$username?" && \
|
ask_ok "User $user's files successfully restored, remove backup at /mnt/array/home-retired/$user?" && \
|
||||||
rm -rf /mnt/array/home-retired/"$username"
|
rm -rf /mnt/array/home-retired/"$user"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# echo "Running: ${useradd_cmd[*]}"
|
# echo "Running: ${useradd_cmd[*]}"
|
||||||
"${useradd_cmd[@]}"
|
"${useradd_cmd[@]}"
|
||||||
echo "$username":"$password" | chpasswd
|
echo "$user":"$password" | chpasswd
|
||||||
|
|
||||||
|
|
||||||
if [[ "$samba" == "yes" ]]; then
|
if [[ "$samba" == "yes" ]]; then
|
||||||
(echo "$password"; echo "$password") | smbpasswd -a -s "$username"
|
(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 "$username"
|
sudo 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
|
||||||
@@ -75,12 +75,12 @@ sudo passwd --expire "$username"
|
|||||||
# last_gid=$(tail -1 /etc/subgid | cut -d':' -f2)
|
# last_gid=$(tail -1 /etc/subgid | cut -d':' -f2)
|
||||||
# start_uid=$(( last_uid + id_offset ))
|
# start_uid=$(( last_uid + id_offset ))
|
||||||
# start_gid=$(( last_gid + id_offset ))
|
# start_gid=$(( last_gid + id_offset ))
|
||||||
# echo "$username:$start_uid:$id_num" >> /etc/subuid
|
# echo "$user:$start_uid:$id_num" >> /etc/subuid
|
||||||
# echo "$username:$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/"$username"/Desktop/
|
mkdir -p /home/"$user"/Desktop/
|
||||||
ln -fs "$parent"/README.html /home/"$username"/Desktop/
|
ln -fs "$parent"/README.html /home/"$user"/Desktop/
|
||||||
chown "$username":"$username" -R /home/"$username"/Desktop
|
chown "$user":"$user" -R /home/"$user"/Desktop
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -7,7 +7,7 @@ parent=${parent%/*}
|
|||||||
|
|
||||||
unset user
|
unset user
|
||||||
|
|
||||||
[[ -f $parent/functions ]] && . "$parent"/functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -7,25 +7,27 @@ unset user password
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
echo "This script supports two optional arguments, a username and password"
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
prompt username
|
prompt user
|
||||||
prompt password
|
prompt password
|
||||||
elif [[ $# -eq 1 ]]; then
|
elif [[ $# -eq 1 ]]; then
|
||||||
username="$1"
|
user="$1"
|
||||||
prompt password
|
prompt password
|
||||||
elif [[ $# -eq 2 ]]; then
|
elif [[ $# -eq 2 ]]; then
|
||||||
username="$1"
|
user="$1"
|
||||||
password="$2"
|
password="$2"
|
||||||
elif [[ $# -gt 2 ]]; then
|
elif [[ $# -gt 2 ]]; then
|
||||||
echo "Too many arguments provided"
|
echo "Too many arguments provided"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! id -u "$username" &>/dev/null; then
|
if ! id -u "$user" &>/dev/null; then
|
||||||
echo "User $user does not exist"
|
echo "User $user does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -5,13 +5,17 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
[[ $# -lt 1 ]] && echo "No username provided!" && exit 1
|
echo "This script supports one optional argument, a username"
|
||||||
[[ $# -ge 1 ]] && user="$1"
|
|
||||||
|
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
|
user="$1"
|
||||||
|
else
|
||||||
|
prompt user
|
||||||
|
fi
|
||||||
|
|
||||||
# Clean local user cache
|
# Clean local user cache
|
||||||
rm -rf /home/"$user"/.x2go/C-"$user"-*
|
rm -rf /home/"$user"/.x2go/C-"$user"-*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
parent="${BASH_SOURCE[0]}"
|
parent="${BASH_SOURCE[0]}"
|
||||||
parent=${parent%/*}
|
parent=${parent%/*}
|
||||||
|
|
||||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# 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
|
||||||
|
|
||||||
[[ -f functions ]] && . functions || exit 1
|
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||||
|
|
||||||
is_root
|
is_root
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user