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

NetOpWibby commented Nov 27, 2023

sh -c "$(curl -fsSL https://gist.githubusercontent.com/NetOpWibby/4b8c4729b18171a1c3d322837835cf68/raw/858f4aa997e73fa831785c792b36adb1f25c5033/install.sh)"

Reboot after.

@NetOpWibby
Copy link
Author

NetOpWibby commented Jan 31, 2024

Ubuntu needs chsh -s /usr/bin/zsh apparently (instead of chsh -s $(which zsh)), to change default shell to zsh.

@NetOpWibby
Copy link
Author

Why do I need to enter chsh -s /usr/bin/zsh AFTER the script runs and the server reboots, for it to stick?

@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