-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
61 lines (51 loc) · 2.16 KB
/
init.sh
File metadata and controls
61 lines (51 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
while [[ -z "$mysql_username" || -z "$mysql_password" ]]; do
clear;
read -p "MYSQL Admin Username: " mysql_username;
read -p "MYSQL Admin Password: " mysql_password;
read -p "Is this information correct [Y/n]: " mysql_correct;
if [ "$mysql_correct" == "n" ]; then
mysql_username=;
mysql_password=;
fi
done
while [[ -z "$username" || -z "$password" || -z "$name" || -z "$email" || -z "$ssh_key=" || -z "$sudoer" ]]; do
clear;
read -p "New Full Name: " name;
read -p "Github Profile Email: " email;
read -p "New Username: " username;
read -p "New Password: " password;
read -p "Local SSH Key: " ssh_key;
read -p "Sudoer [Y/n]: " sudoer;
read -p "Is this information correct [Y/n]: " user_correct;
if [ "$user_correct" == "n" ]; then
username=;
password=;
name=;
email=;
ssh_key=;
sudoer=;
fi
done
clear;
adduser --force-badname $username;
mysql --user="$mysql_username" --password="$mysql_password" -e "CREATE DATABASE laborate_$username;"
mysql --user="$mysql_username" --password="$mysql_password" -e "CREATE USER '$username'@'localhost' IDENTIFIED BY '$password'";
mysql --user="$mysql_username" --password="$mysql_password" -e "GRANT ALL PRIVILEGES ON laborate_$username.* To '$username';"
chmod 775 -R /home/$username;
chown -R root /home/$username;
chgrp -R $username /home/$username;
if [ "$sudoer" == "Y" ]; then
usermod -a -G sudo $username;
fi
su -c "git config --global user.name '$name'" - $username;
su -c "git config --global user.email '$email'" - $username;
su -c "git config --global color.ui auto" - $username;
su -c "git config --global core.editor 'vim'" - $username;
su -c "git config --global merge.tool vimdiff" - $username;
su -c "export VISUAL=vim" - $username;
su -c "export EDITOR=vim" - $username;
su -c "curl https://raw.github.com/creationix/nvm/master/install.sh | sh" - $username;
su -c "cd ~/.ssh; ssh-keygen -t rsa -C '$email'; touch ~/.ssh/authorized_keys;" - $username;
su -c "echo '$ssh_key' >> ~/.ssh/authorized_keys;" - $username;
rm -R "$(cd "$(dirname "$0")"; pwd)/../new_developer";
su -c "clear; cat ~/.ssh/id_rsa.pub" - $username;