-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchroot.sh
executable file
·127 lines (99 loc) · 1.83 KB
/
chroot.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
#!/bin/sh
WITH_GO=0
WITH_RUBY=0
WITH_GIT=0
USER="arch"
PASSWORD="rHDW5xp4hDyaU" # arch
for i in "$@"; do
case $i in
-u=*|--user=*)
USER="${i#*=}"
shift
;;
-p=*|--password=*)
PASSWORD="${i#*=}"
shift
;;
--with-go=*)
WITH_GO="${i#*=}"
shift
;;
--with-ruby=*)
WITH_RUBY="${i#*=}"
shift
;;
--with-git=*)
WITH_GIT="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done
pacman -S --noconfirm vim htop lsof linux-lts sudo ntp openssh lua
pacman -R --noconfirm linux
if [ $WITH_GO != 0 ]; then
pacman -S --noconfirm go go-tools
fi
if [ $WITH_RUBY != 0 ]; then
pacman -S --noconfirm ruby
fi
if [ $WITH_GIT != 0 ]; then
pacman -S --noconfirm git
fi
#
# USERS
#
user=$USER
echo "root:root" | chpasswd
useradd -m -G wheel -U -p eCxS1fXJO8oqQ $user
echo "$user:$user" | chpasswd
#
# VIM
#
cp -a /bootstrap/vim/.vimrc /home/$user/
cp -a /bootstrap/vim/.vim /home/$user/
chown -R $user:$user /home/$user/.vim*
#
# GO
#
if [ $WITH_GO != 0 ]; then
install -d -o $user -g $user -m 775 /home/$user/go/src
chown -R $user:$user /home/$user/go
printf "\nGOPATH=/home/$user/go\nexport GOPATH\nPATH=\"\$GOPATH/bin:$PATH\"\n" >> /home/$user/.bashrc
env GOPATH=/home/$user/go PATH="/home/$user/go/bin:$PATH" go get github.com/nsf/gocode
fi
#
# SUDO
#
perl -pi -e 's/#\s*(%wheel.+NOPASSWD)/$1/' /etc/sudoers
#
# SERIAL CONSOLE
#
systemctl enable [email protected]
#
# SSH
#
install -d -o $user -g $user -m 700 /home/$user/.ssh
install -m 600 -o $user -g $user /bootstrap/ssh/authorized_keys /home/$user/.ssh/
systemctl enable sshd
#
# NTP
#
systemctl enable ntpd
#
# RESIZE THE ROOT FILESYSTEM
#
systemctl enable resize-rootfs
#
# ENABLE NETWORK
#
for f in /bootstrap/network/*; do
interface=`basename $f`
netctl enable $interface
done
#
# LOCK DOWN THE ROOT LOGIN
#
passwd -l root