28 lines
801 B
Bash
Executable File
28 lines
801 B
Bash
Executable File
#!/bin/bash
|
|
# create password
|
|
pw=$(pwgen -1B 10)
|
|
pwcrypt=$(perl -e "print crypt('${pw}', 'sa');")
|
|
|
|
# create account
|
|
useradd -m -g 100 -p "${pwcrypt}" -s /bin/bash "$1" || exit 1
|
|
|
|
# fix perms
|
|
chown -R "$1":tilde /home/"$1"
|
|
chmod -R go-rx /home/"$1"
|
|
chmod go+x /home/"$1"
|
|
chmod go+rx /home/"$1"/public_html
|
|
chmod go+r /home/"$1"/public_html/*
|
|
chmod go+rx /home/"$1"/public_gopher
|
|
chmod go+r /home/"$1"/public_gopher/gophermap
|
|
|
|
# ssh
|
|
mkdir /home/"$1"/.ssh
|
|
touch /home/"$1"/.ssh/authorized_keys
|
|
chmod 700 /home/"$1"/.ssh
|
|
chmod 600 /home/"$1"/.ssh/authorized_keys
|
|
echo "$3" | tee /home/"$1"/.ssh/authorized_keys
|
|
chown -R "$1":tilde /home/"$1"/.ssh
|
|
|
|
# send welcome email
|
|
sed -e "s/USERNAME/$1/g" -e "s/PASSWORD/${pw}/g" /var/aussie/emails/signup.tmpl | sendmail "$1"@aussies.space fosslinux@aussies.space
|