makeuser/makeuser

62 lines
1.4 KiB
Plaintext
Raw Normal View History

2018-09-20 15:18:17 +00:00
#!/bin/bash
# ---------------------------------------------------------------------------
2019-03-27 18:28:49 +00:00
# makeuser - tilde new user creation
# Usage: makeuser [-h|--help] <username> <email> "<pubkey>"
2018-09-20 15:18:17 +00:00
# ---------------------------------------------------------------------------
2019-03-27 18:28:49 +00:00
#
# Forked from tilde.team's make user script (
2018-09-20 15:18:17 +00:00
PROGNAME=${0##*/}
2019-03-27 18:28:49 +00:00
VERSION="0.4"
2019-11-05 15:57:19 +00:00
GEN_TDP="./gen_tdp"
2019-12-06 13:01:38 +00:00
CONFIG=./setenv
2019-11-05 15:57:19 +00:00
2019-12-06 13:01:38 +00:00
. $CONFIG
2018-09-20 14:04:19 +00:00
2019-12-12 20:15:11 +00:00
source include/functions
2018-12-15 01:29:03 +00:00
2019-03-27 18:28:49 +00:00
[[ $(id -u) == 0 ]] && error_exit "Do not run this script as root."
case $1 in
-h | --help)
usage; exit ;;
-* | --*)
usage; error_exit "unknown option $1" ;;
*)
[[ $# -ne 3 ]] && error_exit "not enough args"
$(sudo grep -qiw $1 $BANNED) && error_exit "$1 is on the ban list!"
#adding new user
makeuser_no_ansible $1 $2
add_account_recovery $1 $2
2019-03-27 18:28:49 +00:00
#Thunix specific section
currdir=`pwd`
2020-10-08 22:48:22 +00:00
cd $REPO_LOCATION; git pull
2019-03-27 18:28:49 +00:00
echo "---
- name: Setting up $1
user:
name: $1
groups: tilde
state: present
skeleton: /etc/skel
shell: /bin/bash
system: no
createhome: yes
home: /home/$1
- authorized_key:
user: $1
state: present
2019-04-01 16:49:06 +00:00
key: \"$3\"" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE
2019-03-27 18:28:49 +00:00
2019-04-01 16:49:06 +00:00
echo "- include: users/$YAML_FILE" >> $REPO_LOCATION/roles/shell/tasks/users.yml
2019-04-04 01:55:01 +00:00
git add $REPO_LOCATION/roles/shell/tasks/users/$1.yml
2019-03-27 18:28:49 +00:00
git commit -am "Adding user $1"
2019-04-04 01:55:01 +00:00
git push
2020-10-08 22:48:22 +00:00
cd $currdir
2019-11-05 15:57:19 +00:00
$GEN_TDP | sudo tee $TILDE_JSON
2019-03-27 18:28:49 +00:00
# End Thunix specific section
;;
esac
2018-09-21 14:04:48 +00:00