diff --git a/src/common/info.sh b/src/common/info.sh deleted file mode 100644 index ac6891b..0000000 --- a/src/common/info.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -wget -O /opt/scripts/info https://git.io/vaHfR; -chmod +x /opt/scripts/info -ln -s /opt/scripts/info /opt/bin -/opt/bin/info \ No newline at end of file diff --git a/src/common/install-info.sh b/src/common/install-info.sh new file mode 100644 index 0000000..184b2b5 --- /dev/null +++ b/src/common/install-info.sh @@ -0,0 +1,10 @@ +#!/bin/bash +wget --quiet -O /opt/scripts/info https://git.io/vaHfR > /dev/null +if [[ -f /opt/scripts/info ]]; then + chmod +x /opt/scripts/info + ln -sf /opt/scripts/info /opt/bin/ + else + echo Failed to download + echo "https://raw.githubusercontent.com/KittyKatt/screenFetch/master/screenfetch-dev" + echo info screen not available + fi diff --git a/src/common/permitmod b/src/common/permitmod new file mode 100644 index 0000000..8f1f23c --- /dev/null +++ b/src/common/permitmod @@ -0,0 +1,8 @@ +# allow admins to change group and user ids +sysadmin ALL = NOPASSWD : ALL +# sysadmin ALL = NOPASSWD:/sbin/groupmod +# sysadmin ALL = NOPASSWD:/sbin/usermod +# sysadmin ALL = NOPASSWD:/sbin/adduser +# sysadmin ALL = NOPASSWD:/sbin/addgroup +# sysadmin ALL = NOPASSWD:/sbin/useradd +# sysadmin ALL = NOPASSWD:/sbin/groudadd diff --git a/src/common/adduser.sh b/src/common/readme.md similarity index 100% rename from src/common/adduser.sh rename to src/common/readme.md diff --git a/src/common/ucishell.sh b/src/common/ucishell.sh deleted file mode 100755 index 1222702..0000000 --- a/src/common/ucishell.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -DIR=$(cd "$(dirname "$BASH_SOURCE")" >/dev/null 2>&1 ; pwd -P ) -if [ $EUID != 0 ]; then - sudo $DIR/deploy.sh $(whoami) -fi - -BASH_SHELL_BASE="$(dirname $DIR)" -echo Base Shell Directory as detected is $BASH_SHELL_BASE -echo -----------------;echo deploying /etc shell files -files=$(find $BASH_SHELL_BASE/setup/etc/ -maxdepth 1 -type f) -for file in $files; do install -m 644 -o root -g root $file /etc; done -echo setting BASH_SHELL_BASE to $BASH_SHELL_BASE in etc/bash.bashrc and /etc/profile -sed -i 's:_BASH_SHELL_BASE_:'${BASH_SHELL_BASE}':' /etc/bash.bashrc -sed -i 's:BASH_SHELL_BASE=.*:BASH_SHELL_BASE='${BASH_SHELL_BASE}':' /etc/profile -files=$(find $BASH_SHELL_BASE/setup/etc/profile.d -maxdepth 1 -type f) -for file in $files; do install -m 644 -o root -g root $file /etc/profile.d; done -echo -----------------;echo deploying /root shell files -group=root -files=$(find $BASH_SHELL_BASE/setup/root/ -type f) -for file in $files; do install -m 640 -o root -g $group $file /root; done -echo ----------------- - diff --git a/src/common/user.sh b/src/common/user.sh deleted file mode 100755 index a1c42be..0000000 --- a/src/common/user.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash - -# clone a user - -# adduserid name id# -# add a suer with specific id number -# adduserid () { -# sudo groupadd -g $2 $1 -# sudo useradd -d ${/home/$1} -s /bin/bash -u $2 -g $1 $1 -# } - -adduserid() { - -[[ "$#" -lt 1 ]] && echo a user name is requied, aborting && return 1 -name=$1 -uid=${2:-1000} -gid=${3:-$uid} -echo $name, $uid, $gid - -[[ $(getent group $gid) ]] && echo group id $gid already exists, aborting && return 3 -[[ $(getent group $name) ]] && echo group name $name already exists, aborting && return 3 -[[ $(getent passwd $uid) ]] && echo user id $uid already exists, aborting && return 2 -[[ $(getent passwd $name) ]] && echo user name $name already exists, aborting && return 2 - -echo addgroup --gid $gid $name -echo adduser -u $uid -G $name -g "" -D -H $name -# cat /etc/group | grep $name && cat /etc/passwd | grep $name - -} - -function clone_user_ () { - - module_load confirm - - echo "=============" - echo "this script will create a new user" - echo "based on an existing user's data" - echo - echo "You will be shown a list of users who can currently log on" - echo "Remember which user you would like to clone." - echo "You will be asked for the new user's name, their password" - echo "and the old user to clone". - echo "=============" - echo - - echo -n "New user's name: " - read newuser - - echo -n "New user's password: " - read newpassword - - echo - - echo "Current users you can clone:" - echo "----" - awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd - echo - - echo -n "Old user to clone: " - read olduser - echo "olduser uid is $(id -u $olduser)" - - echo - echo "You have selected: " - echo "----" - echo "new user: $newuser" - echo "new user password: $newpassword" - echo "old user: $olduser" - echo - - olduser_GROUPS="$(id -Gn ${olduser} | sed "s/${olduser} //g" | sed "s/ ${olduser}//g" | sed "s/ /,/g"),$olduser" - olduser_SHELL=$(awk -F : -v name=${olduser} '(name == $1) { print $7 }' /etc/passwd) - - echo "old user groups: " - echo "----" - echo $olduser_GROUPS - echo "olduser shell: " - echo $olduser_SHELL - - confirm "ready to clone user, begin?" || return 1 - - useradd --groups $olduser_GROUPS --shell $olduser_SHELL $newuser - - echo $newuser:$newpassword | chpasswd - - read -rsp $'ready to make home direcoty -- ctrl-c to exit...\n' -n1 key - - mkdir /home/$newuser - chown -R $newuser:$newuser /home/$newuser - - echo - echo "Script should be done now." - echo - echo "Do you see your new users name below?" - echo - awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd - - echo - echo "We are now going to copy the old user's home folder to the new user" - echo "then change ownership to the new user" - echo - read -rsp $'Ready to copy home folder --- or ctrl-c to exit...\n' -n1 key - - rsync -aPv --exclude 'Downloads' /home/$olduser/. /home/$newuser/ - chown -R --from=$olduser $newuser:$newuser /home/$newuser - - echo - echo "Now we are going to change the names of files and folders to the new user" - echo - - grep -rlI $olduser /home/$newuser/ . | sudo xargs sed -i 's/$olduser/$newuser/g' - - echo - echo "Done now." - echo - read -rsp $'Press any key to exit...\n' -n1 key - echo - echo - -} - -clone_user () { - if [[ $EUID != 0 ]]; then - - clone=$(declare -f clone_user_) - module_load confirm - confirm=$(declare -f confirm) - sudo bash -c "$confirm; $clone; clone_user_" - else - echo run as regular user with sudo privliges and it will elevate - fi -} - -rename_user () { - - module_load confirm - local force; local name; local newname; local newhome - - [[ $1 = "-f" ]] && { force=true; shift 1; } - [[ $1 = "-h" ]] && { newhome=$2; shift 2; } - # usage: < -f, -h newhome > name newname - # default new user home is /home/newname - name=$1 - newname=$2 - if [[ ! ($name && $newname) ]]; then - echo "=============" - echo "this script will rename an existing user" - echo "user running this script must to root or have sudo priviledges to run" - echo "---- Available Users to Rename ---" - awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd - echo "=============" - read -r -p "Enter an available user name: " name - read -r -p "Enter users new name: " newname - read -r -p "Enter users new home directory : " newhome - fi - - newhome=${newhome:-/home/$newname} - - if [[ ! $force ]]; then - echo "Changing $name to $newname with home $newhome" - echo sudo usermod -l $newname $name - echo sudo groupmod -n $newname $name - echo sudo usermod --d $newhome --m $name - confirm -s "These are the commands that will be run. Do you want to continue?" || return 1 - fi - - sudo usermod -l $newname $name - echo sudo groupmod -n $newname $name - echo sudo usermod --d $newhome --m $name -}