-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-install
More file actions
executable file
·192 lines (155 loc) · 5.95 KB
/
post-install
File metadata and controls
executable file
·192 lines (155 loc) · 5.95 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
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
#!/bin/bash -e
#Make sure we are running as root.
if [ "$UID" != "0" ] ; then
echo 'Run this script with sudo'
exit 1
fi
#This scripts directory, used to find the pprint script
DIR=$(cd $(dirname "$0"); pwd)
#Make messages display better
source $DIR/pprint
function errexit {
echo trapped
mail_log "ERROR" "The post-install script failed!"
}
#Changing the log file
export LOGFILE='post-install.log'
#Get a fresh log file
if [ -e "$LOGFILE" ] ; then rm "$LOGFILE" ; fi
#Current distro's adjective name used for apt.
if [ -f /etc/apt/sources.list.d/official-package-repositories.list ] ; then
ADJECTIVE=$( grep -m 1 'ubuntu' /etc/apt/sources.list.d/official-package-repositories.list | cut -d ' ' -f 3 )
else
ADJECTIVE=$( grep -m 1 'deb.*ubuntu' /etc/apt/sources.list | cut -d ' ' -f 3 )
fi
#Virtualbox package to install
VBOX='virtualbox-4.3'
#List of applications to install
APPS="vlc browser-plugin-vlc mpg321 espeak python3-pip \
vim-gnome git cscope vim-doc build-essential \
rdiff-backup alltray libreoffice \
sshfs openssh-server filezilla deluge exfat-fuse exfat-utils \
ssmtp bsd-mailx inotify-tools wallch"
#Install the Virtualbox and Chrome repository keys
if ! wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - ; then
die_log 'Failed to add the VirtualBox repository key'
fi
if ! wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - ; then
die_log 'Failed to install Chrome repository key'
fi
#Add virtual box repository apt list file
cat >/etc/apt/sources.list.d/virtualbox.list <<EOF
deb http://download.virtualbox.org/virtualbox/debian $ADJECTIVE contrib
EOF
#Add the Chrome repository apt list file
cat >/etc/apt/sources.list.d/google-chrome.list <<EOF
deb http://dl.google.com/linux/chrome/deb/ stable main
EOF
#Install the SimpleScreenRecorder repositiory
if ! add-apt-repository ppa:maarten-baert/simplescreenrecorder -y ; then
die_log 'Failed to install SimpleScreenRecorder Repo'
fi
#Make the sources changes take effect
if ! ( apt-get update || apt-get update ) ; then
die_log 'Could not update repository list to make source.list changes take effect'
fi
#Get currently installed software one at a time
dpkg --get-selections > /tmp/selections
#Install the applications
if ! apt-get -y install $APPS ; then
die_log "Could not install all of the applications"
fi
#Install VirtualBox if it is not already installed
if ! grep -q "$VBOX" /tmp/selections ; then
if ! apt-get -y install $VBOX ; then
die_log "Could not install $VBOX"
fi
fi
#Install Chrome if it not already installed
if ! grep -q "google-chrome-stable" /tmp/selections ; then
if ! apt-get -y install google-chrome-stable ; then
die_log "Could not install Google Chrome"
fi
fi
#Install SimpleScreenRecorder if not already installed
if ! grep -q 'simplescreenrecorder' /tmp/selections ; then
if ! apt-get -y install simplescreenrecorder ; then
die_log "Could not install SimpleScreenRecorder"
fi
fi
#Install the proprietary video driver
info_log 'Installing any needed proprietary drivers'
if ! ubuntu-drivers autoinstall ; then
die_log 'Failed to install proprietary drivers'
fi
#BUG FIX: Mint uses the old 2.x version of Gedit instead of
#the newer version. The fix works by installing the Ubuntu
#version of the packages instead of the Mint versions. I have
#farmed this out to a separate script.
if ! "$DIR/upgrade-to-gedit3" ; then
die_log 'Failed to upgrade Gedit 2.x to Gedit 3.x'
fi
#Install Pylint via PIP
if ! pip3 install pylint ; then
warn_log 'Failed to install Pylint'
fi
#Clean up selections file
rm /tmp/selections
#Add regular users to the vboxusers group
#Regular users are determined by having a UID between 1000-1999
for me in $( grep 'x:1[0-9]\{3\}:' /etc/passwd | cut -f 1 -d : ) ; do
if ! getent group vboxusers | grep -q $me ; then
if ! adduser $me vboxusers ; then
die_log "Could not add user '$me' to group 'vboxusers'"
fi
fi
done
#Upgrade the system
info_log 'Upgrading the system'
if ! ( apt-get -y upgrade && apt-get -y dist-upgrade && \
apt-get -y autoremove && apt-get -y clean ) ; then
die_log 'Upgrade failed'
fi
#Setup NetworkManager configuration files
if ! "$DIR/setup-nm" ; then
die_log "Failed to properly setup NetworkManager configuration"
fi
#Adjust the sudoers file so it does not ask for a password
info_log 'Fixing sudoers file'
if ! cp -v /etc/sudoers /tmp/sudoers.tmp ; then
die_log 'Could not copy sudoers to begin no password change'
elif ! sed -i 's/^%admin.*$/%admin ALL=NOPASSWD:ALL/' /tmp/sudoers.tmp ; then
die_log 'Could not replace ALL with NOPASSWD field in admin.'
elif ! sed -i 's/^%sudo.*$/%sudo ALL=NOPASSWD:ALL/' /tmp/sudoers.tmp ; then
die_log 'Could not replace ALL with NOPASSWD field in sudoers.'
elif ! mv -v /tmp/sudoers.tmp /etc/sudoers ; then
die_log 'Could not replace sudoers file with new one.'
fi
#Make the backup script active
info_log Creating backup script link
if [ ! -e /etc/cron.daily/backup-home ] ; then
if ! sudo ln -vs $DIR/backup-home /etc/cron.daily/ ; then
die_log 'Could not create the backup script symlink'
fi
fi
#Make the automatic upgrade script active
info_log Creating automatic upgrade link
if [ ! -e /etc/cron.daily/upgrade ] ; then
if ! sudo ln -vs $DIR/upgrade /etc/cron.daily/ ; then
die_log 'Could not create the upgrade script symlink'
fi
fi
#Add the servers as SSH FS's to the fstab file
$DIR/add-sshfs-to-fstab
#Set up ssmtp
info_log Setting up ssmtp.conf
cp -v $DIR/etc/ssmtp.conf /etc/ssmtp
chmod 640 /etc/ssmtp/ssmtp.conf
chown root:mail /etc/ssmtp/ssmtp.conf
#I like cronttab to run daily, weekly, etc at 3 in the morning
#so replace it with my on cronttab
cp -v {$DIR,}/etc/crontab
#Send an email when the post install is finished.
#This acts as a test for whether the ssmtp config
#worked.
mail_log 'Post install script finished successfully' 'No problems to report'