Skip to content

Instantly share code, notes, and snippets.

@NetOpWibby
Last active June 4, 2024 22:13
Show Gist options
  • Save NetOpWibby/4b8c4729b18171a1c3d322837835cf68 to your computer and use it in GitHub Desktop.
Save NetOpWibby/4b8c4729b18171a1c3d322837835cf68 to your computer and use it in GitHub Desktop.
server setup
#!/bin/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
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 "+ Updating and upgrading packages… +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""
apt update && apt upgrade -y
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 "+ Package cleanup +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""
apt autoremove -y
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ Server setup complete! You should reboot now +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo ""
@NetOpWibby
Copy link
Author

Okay, entering zsh and then chsh -s /usr/bin/zsh after the script finishes works.

@NetOpWibby
Copy link
Author

Rebooting makes zsh the default shell at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment