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
#!/bin/bash

###########################################################################
#                                                                         #
# Running unknown scripts from somewhere is EXTREMELY DANGEROUS practice! #
# If you absolutely trust the source and can understand what the script   #
# does... then maybe!                                                     #
#                                                                         #
###########################################################################
#
# This is for Ubuntu 22.04 student servers and newer
#
# Automatic install with curl & sudo:
#
# curl -s -L https://tl.oamk.fi/cdos/dl/install.bash | sudo bash
#


if [ "$EUID" -ne 0 ]; then
    echo "Please run as root (with sudo). So, something like:"
    echo "curl -s -L https://tl.oamk.fi/cdos/dl/install.bash | sudo bash"
    exit
fi

# Installing some common tools and packages. uninstall annoying needrestart

apt purge needrestart -y
export DEBIAN_FRONTEND=noninteractive
apt upgrade -y --force-yes
apt install vim nano net-tools unattended-upgrades htop jq lynx w3m bat zip unzip ncdu p7zip-full tree -y

# Common for development. Not installing these by default
# apt install build-essential python3-pip python3-venv git -y

# These are funny but quite useless. Not installing these by default
# apt install fortune-mod lolcat cowsay toilet figlet cmatrix sl pv aview sysvbanner -y

# cleaning
apt autoremove -y

# system wide nano settings

cat << EOF >> /etc/nanorc

# See: https://www.nano-editor.org/dist/latest/nanorc.5.html

set titlecolor bold,white,blue
set minicolor bold,white,blue
set promptcolor lightwhite,green
set statuscolor bold,white,green
set errorcolor bold,white,red
set spotlightcolor black,lightyellow
set selectedcolor lightwhite,magenta
set stripecolor ,yellow
set scrollercolor cyan
set numbercolor cyan
set keycolor cyan
set functioncolor green

#set indicator
#set autoindent
#set nonewlines
#set cutfromcursor
#set linenumbers
#set softwrap

set wordchars "<_>."
set atblanks
set historylog
set tabsize 4
set tabstospaces
set regexp
set locking
set constantshow
set nohelp
set boldtext
set afterends
set minibar
set stateflags
set zap
set locking
set boldtext

bind ^Z suspend main
bind ^N findnext all
bind ^P findprevious all
bind ^F whereis all

EOF

# disable ubuntu pro ads, TZ to EET. Avoid swap memory

pro config set apt_news=false
timedatectl set-timezone Europe/Helsinki
grep -q 'vm.swappiness' /etc/sysctl.conf || echo 'vm.swappiness = 1' >> /etc/sysctl.conf

# System wide setting cygwin TERM to xterm-256color (cygwin is cmder default term for SSH)

cat << EOF >> /etc/profile

# Some defaults expected such as 256 color terminal

if [ \$TERM == "cygwin" ]; then export TERM="xterm-256color"; fi

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS2='> '
PS4='+ '

alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

EOF

# Server-side SSH keep-alives

cat << EOF >> /etc/ssh/sshd_config

ClientAliveInterval 300
ClientAliveCountMax 2

EOF

echo
echo 'For kernel security updates to apply and such, consider restarting the Linux server with: sudo reboot'
echo