dotfiles/setup.sh

66 lines
1.7 KiB
Bash

#!/bin/sh -e
if [ ! -x "$(command -v git)" ]; then
echo "Please install git first."
exit 1
fi
if [ ! -f /etc/doas.conf ]; then
echo "Please configure doas, then re-run this script as a normal user."
exit 1
fi
chmod 700 ~
# Remove stuff OpenBSD adds by default that I don't need
rm -f ~/.cshrc ~/.cvsrc ~/.login ~/.mailrc ~/.Xdefaults ~/.profile
# Create directory structure
mkdir -p \
~/Documents/Projects \
~/Music \
~/Pictures \
~/Downloads \
~/.ssh
# Grab latest dotfiles and apply them to the system
git clone https://git.merveilles.town/jbauer/dotfiles ~/Documents/Projects/dotfiles
cd ~/Documents/Projects/dotfiles
echo "Copying user configuration files"
for file in .????*; do
cp -r "$file" ~
done
echo "Copying etc/ files"
doas cp -r etc/* /etc/
doas chmod 744 /etc/apm/*
doas chmod 744 /etc/hotplug/*
echo "pkill xmessage" | cat - /etc/X11/xenodm/GiveConsole > /etc/X11/xenodm/GiveConsole
groups="staff,_shutdown"
echo "Adding user $USER to groups: $groups"
doas usermod -G $groups jbauer
echo "Setting shell for $USER to $(which fish)"
doas chsh -s $(which fish) jbauer
echo "Enabling power management services"
doas rcctl enable obsdfreqd apmd
doas rcctl set apmd flags -L -z5
doas rcctl start obsdfreqd apmd
echo "Configuring syncthing to run on startup"
echo "@reboot tmux new-session -d '/usr/local/bin/syncthing'" | crontab -
echo "Linking /usr/bin/openrsync -> /usr/bin/rsync"
doas ln -s /usr/bin/openrsync /usr/bin/rsync
echo "Installing packages, you might want to grab a cup of tea..."
doas pkg_add -l ~/Documents/Projects/dotfiles/pkg_base
echo "========="
echo "All done!"
echo "========="
echo "Don't forget to increase openfiles-max and openfiles-cur in /etc/login.conf for the staff group."