-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·207 lines (166 loc) · 3.98 KB
/
run.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#! /bin/bash
set +e
if getent passwd deef > /dev/null 2>&1; then
echo "User deef already exists"
else
while true; do
read -p "Create User Deef? [y/n]" yn
case $yn in
[Yy]*)
useradd --home /home/deef --create-home --shell /bin/bash deef
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
fi
#This program runs an automated script that loads in all the necessary files such as public keys and alias files and file structures
#check for sudo
#if [[ $EUID -ne 0 ]]; then
# echo "This script must be run as root"
# exit 1
#fi
while true; do
read -p "Set New Hostname? [y/n]" yn
case $yn in
[Yy]*)
read -p "Enter New Hostname: " name
sudo hostnamectl set-hostname $name
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Move files into home? [y/n] (Not needed if appending to .bashrc)" yn
case $yn in
[Yy]*)
#move bash aliases to home directory
cp -f .bash_aliases ~/.bash_aliases
cp -f .dircolors ~/.dircolors
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Append 'source .bash_alisese' to .bashrc? [y/n]" yn
case $yn in
[Yy]*)
#move bash aliases to home directory
echo "test -f ~/startup/.bash_aliases && . ~/startup/.bash_aliases" >> ~/.bashrc
test -f ~/.bash_profile && echo "test -f ~/.bashrc && . ~/.bashrc" >> ~/.bash_profile
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Move files into root? [y/n]" yn
case $yn in
[Yy]*)
#move bash aliases to home directory
sudo cp -f .bash_aliases /root/.bash_aliases
sudo cp -f .dircolors /root/.dircolors
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "update/upgrade/install? [y/n]" yn
case $yn in
[Yy]*)
sudo apt update
sudo apt upgrade
sudo apt install openssh-server htop
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Update Key Settings? [y/n]" yn
case $yn in
[Yy]*)
#force no root login over ssh
sudo sed -i 's/#\?\s*\(PermitRootLogin\s*\).*$/\1 no/' /etc/ssh/sshd_config
#force no password authentication over ssh
sudo sed -i 's/#\?\s*\(PasswordAuthentication\s*\).*$/\1 no/' /etc/ssh/sshd_config
#force allow public key authentication
sudo sed -i 's/#\?\s*\(PubkeyAuthentication\s*\).*$/\1 yes/' /etc/ssh/sshd_config
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
#replace authorized keys file to .ssh/authorized_keys
while true; do
read -p "Add authorized Keys? [y/n]" yn
case $yn in
[Yy]*)
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
cat authorized_keys >>~/.ssh/authorized_keys
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Add authorized Keys to root? [y/n]" yn
case $yn in
[Yy]*)
sudo mkdir /root/.ssh
sudo touch /root/.ssh/authorized_keys
sudo cat authorized_keys >>/root/.ssh/authorized_keys
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Regenerate SSH Server Keys? [y/n]" yn
case $yn in
[Yy]*)
sudo rm -v /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
sudo systemctl restart ssh
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
while true; do
read -p "Install Golang? [y/n]" yn
case $yn in
[Yy]*)
rm update-golang.sh
wget https://raw.githubusercontent.com/udhos/update-golang/master/update-golang.sh
sudo bash ./update-golang.sh
break
;;
[Nn]*) break ;;
*) echo "Please answer yes or no." ;;
esac
done
#echo setting git user
#set git user
#read -p "Enter name for git [Jeffrey Koehler Auto]: " name
#name=${name:-"Jeffrey Koehler Auto"}
#git config --global user.name $name
#set git email
#read -p "Enter name for git [jeffreykoehlerauto@deef.tech]: " email
#email=${email:-"jeffreykoehlerauto@deef.tech"}
#git config --global user.email $email
source ~/.bashrc