summaryrefslogtreecommitdiff
path: root/server.sh
blob: 33f9bf4fb72290620979adf8a47aee1421de1997 (plain) (blame)
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
#!/bin/sh

# HOW TO USE:
# sh -c "$(curl -fsSL https://script.webb.page/server.sh)"

# exit script if something fails
set -e

# disable "pending kernel upgrade" popup | https://askubuntu.com/a/1424249
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf

# ignore "daemons using outdated libraries" popup | https://stackoverflow.com/a/73397110#comment131834051_73397970
sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf

# suppress interactive prompts from apt (keep existing configs, don't ask)
export DEBIAN_FRONTEND=noninteractive
export NEEDRESTART_MODE=a

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Setting timezone to US Pacific…                        +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

ln -fs /usr/share/zoneinfo/US/Pacific /etc/localtime
dpkg-reconfigure -f noninteractive tzdata

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Setting locale to US English…                          +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

echo "locales locales/default_environment_locale select en_US.UTF-8" | debconf-set-selections
echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | debconf-set-selections
rm "/etc/locale.gen"
dpkg-reconfigure --frontend noninteractive locales

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Updating and upgrading packages…                       +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

apt update
apt upgrade -y -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef"

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing packages we like to use…                    +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

apt install eza unzip -y

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing caddy…                                      +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

apt install debian-keyring debian-archive-keyring apt-transport-https curl -y
curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt" | tee /etc/apt/sources.list.d/caddy-stable.list
apt update -y
apt install caddy -y

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing zsh/ohmyzsh…                                +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

apt install zsh -y
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

# make zsh default shell
command -v zsh | tee -a /etc/shells
chsh -s $(which zsh) $USER

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing deno…                                       +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

curl -fsSL https://deno.land/install.sh | sh

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing bun…                                        +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

curl -fsSL https://bun.sh/install | bash

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Installing avahi…                                      +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

if ! command -v avahi-daemon > /dev/null 2>&1; then
  apt install avahi-daemon -y
  systemctl enable --now avahi-daemon
fi

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Package cleanup                                        +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""

apt autoremove -y

echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Server setup complete! You should reboot now           +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""