david/scripts-archive
david
/
scripts-archive
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-archive/kvm-tools/firstboot.sh

67 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#######################################
## ##
## firstboot script ##
## kvm-tools ##
## ##
#######################################
# **** configuration section ****
sshgroup="sshusers"
user=$(cat /etc/passwd | grep 1000)
user=${user:0:$(($(echo `expr index "$user" :`)-1))}
# **** installing fortunes-ubuntu-server ****
apt-get update
apt-get install -y fortunes-ubuntu-server
# **** motd ****
echo 'if you want to have here something like this:
___.
\_ |__ _______ ___
| __ \ / _ \ \/ /
| \_\ ( <_> > <
|___ /\____/__/\_ \
\/ \/.socialnerds.org
socialnerds mail server
go to http://www.network-science.de/ascii/ and modify /etc/motd.tail
' > /etc/motd.tail
rm /etc/update-motd.d/10-help-text
rm /etc/update-motd.d/00-header
echo '#!/bin/bash' > /etc/update-motd.d/00-header
echo 'echo "Running Kernel: $(uname -r)"' >> /etc/update-motd.d/00-header
chmod +x /etc/update-motd.d/00-header
# **** ssh server config ****
echo "
__.-._
'-._'7'
/'.-c
| /T
_)_/LI
this machine is
protected by a
master of the force!
" > /etc/issue.net
sed -i 's/#Banner/Banner/' /etc/ssh/sshd_config
echo "" >> /etc/ssh/sshd_config
echo "# Restrictions added by firstboot.sh" >> /etc/ssh/sshd_config
echo "AllowGroups $sshgroup" >> /etc/ssh/sshd_config
echo "" >> /etc/ssh/sshd_config
addgroup $sshgroup
adduser $user $sshgroup
# **** end of script ****
exit 0