-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_system.sh
executable file
·209 lines (178 loc) · 4.7 KB
/
setup_system.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
208
209
#!/bin/bash
# Set dev system
# Docker is installed in setup_docker.sh because it keeps changing.
if [[ "$1" == "xorg" ]] ; then
echo "Installing Xorg environment."
XORG='True'
else
echo "Installing shell environment. For X11 use: $0 xorg"
XORG=''
fi
if [[ $(id -u) != 0 ]]; then
echo "Must be root to install packages"
exit 2
fi
if [[ -f '/etc/os-release' ]]; then
source /etc/os-release
else
ID=$(cat /etc/issue | head -1 | cut -f1 -d " ")
fi
PKGS=(
bzip2
dkms
gcc
git
jq
make
nmap
perl
rsync
tmux
traceroute
tree
vagrant
wget
)
DEB_PKGS=(
build-essential
git-flow
libxml2-dev
libxslt-dev
nc
python-devel
python3
python3-dev
python3-pip
ruby-dev
vim-athena
unattended-upgrades
ldap-utils
awscli
)
RHEL_PKGS=(
gitflow
kernel-devel
kernel-headers
nmap-ncat
python-devel
ruby-devel
vim-enhanced
)
FEDORA_PKGS=(
gcc-c++
)
ARCH_PKGS=(
dmidecode
mlocate
python
ruby
dina-font
vim
openssh
bind-tools
net-tools
ntp
)
# RDP app
# remmina
# remmina-plugins-rdp
GEMS=(
rubocop
)
function main {
# Install dotfiles
for F in .bashrc .profile .inputrc .vimrc .dircolors .tmux.conf .gitconfig .rubocop.yml ; do
wget --no-check-certificate https://raw.github.com/apowers/home/master/$F -O /etc/skel/$F
done
source ~/.bashrc
case $ID in
[Aa]rch)
arch_packages
;;
[uU]buntu|[dD]ebian)
debian_packages
;;
[cC]ent[oO][sS]|[rR]ed[hH]at)
rhel_packages
;;
[fF]edora)
fedora_packages
# subpixel rendinging from freetype-freeworld, may not be necessary
#echo "Xft.lcdfilter: lcddefault" > ~/.Xresources
;;
*)
echo "Unsupported Operating System: $ID"
exit 3
esac
# Ruby Gems
/usr/bin/gem install ${GEMS[@]} --no-rdoc --no-ri
}
function debian_packages {
DEBIAN_FRONTEND=noninteractive;
RUNLEVEL=1
APT_OPTS='-qq -y'
echo force-confold >> /etc/dpkg/dpkg.cfg.d/force_confold;
echo 'Dpkg::Options{"--force-confdef";"--force-confold";}' >> /etc/apt/apt.conf.d/local
/usr/bin/apt ${APT_OPTS} upgrade
/usr/bin/apt ${APT_OPTS} install ${PKGS[@]}
/usr/bin/apt ${APT_OPTS} install ${DEB_PKGS[@]}
unset RUNLEVEL
pip3 install pylint
pip3 install autopep8
pip3 install boto3
#Configure unattended-upgrades
APT_CFG_FILE="/etc/apt/apt.conf.d/20apt-periodic-upgrades"
echo 'APT::Periodic::Enable "1";' > ${APT_CFG_FILE}
echo 'APT::Periodic::Update-Package-Lists "1";' >> ${APT_CFG_FILE}
echo 'APT::Periodic::Unattended-Upgrade "1";' >> ${APT_CFG_FILE}
echo 'APT::Periodic::AutocleanInterval "21";' >> ${APT_CFG_FILE}
}
function rhel_packages {
yum upgrade -q -y 2>&1 >/dev/null;
yum install -q -y ${PKGS[@]} 2>&1 >/dev/null;
yum install -q -y ${RHEL_PKGS[@]} 2>&1 >/dev/null;
}
function fedora_packages {
if [[ ! -z $XORG ]] ; then
# RPM Fusion for freetype
RPMFUSION_URL='http://download1.rpmfusion.org/free/fedora'
RPMFUSION_REPO='rpmfusion-free-release-22.noarch.rpm'
/usr/bin/wget -O /tmp/$RPMFUSION_REPO $RPMFUSION_URL/$RPMFUSION_REPO 2>&1 /dev/null;
rpm -i /tmp/$RPMFUSION_REPO 2>&1 >/dev/null;
dnf install -q -y freetype-freeworld 2>&1 >/dev/null;
fi
dnf upgrade -q -y 2>&1 >/dev/null;
dnf install -q -y ${PKGS[@]} 2>&1 >/dev/null;
dnf install -q -y ${RHEL_PKGS[@]} 2>&1 >/dev/null;
dnf install -q -y ${FEDORA_PKGS[@]} 2>&1 >/dev/null;
}
# This function does a bit more than just install packages because Arch is Arch.
# See ArchSetup.md for more information.
function arch_packages {
/usr/bin/pacman -S --noconfirm ${PKGS[@]} 2>&1 >/dev/null;
/usr/bin/pacman -S --noconfirm ${ARCH_PKGS[@]} 2>&1 >/dev/null;
/bin/updatedb
echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/wheel
# AUR package manager
cd /tmp
wget -k https://aur.archlinux.org/cgit/aur.git/snapshot/apacman.tar.gz
tar -xf /tmp/apacman.tar.gz
cd /tmp/apacman
chown nobody .
sudo -u nobody makepkg -rsi --noconfirm
# Language
echo en_US.UTF-8 UTF-8 > /etc/locale.gen
locale-gen
cp /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.avail/11-sub-pixel-rgb.conf
sed -i 's/append/assign/' /etc/fonts/conf.avail/11-sub-pixel-rgb.conf
# Virtualbox Drivers
case $(dmidecode -s system-product-name) in
VirtualBox)
pacman -S --noconfirm linux-headers virtualbox-guest-utils virtualbox-guest-dkms
systemctl enable dkms.service
dkms autoinstall
;;
*) ;;
esac
}
main