install script for serverhost
asd
This commit is contained in:
1 parent
2e273985b7
commit
dbb8eda1e6
1 file changed
+106
@@ -0,0 +1,106 @@
|
||||
# Update system
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
# Install Git, Flatpak and NFS Server
|
||||
sudo apt install -y unattended-upgrades apt-listchanges etherwake git flatpak nfs-kernel-server ca-certificates curl smartmontools curl
|
||||
# Configure Updates
|
||||
sudo dpkg-reconfigure -plow unattended-upgrades
|
||||
# Add flatpak repo
|
||||
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
# Install Moonlight
|
||||
sudo flatpak install -y flathub com.moonlight_stream.Moonlight
|
||||
# Install Jellyfin Media Player
|
||||
sudo flatpak install flathub org.jellyfin.JellyfinDesktop
|
||||
# Create NFS share
|
||||
echo "/torrent/qbittorrent/downloads 192.168.0.4(rw,sync,no_subtree_check)
|
||||
/backup/homeassistant 192.168.0.4(rw,sync,no_subtree_check)
|
||||
" | sudo tee -a /etc/exports
|
||||
sudo exportfs -ra
|
||||
sudo systemctl enable --now nfs-kernel-server
|
||||
# Show active exports
|
||||
sudo exportfs -v
|
||||
# Create user without password
|
||||
sudo adduser media
|
||||
# Add to common groups (optional)
|
||||
sudo passwd -d media
|
||||
# Clone and move git repo
|
||||
git clone https://code.someoneslinux.selfhost.eu/lucas/Server-scripts.git
|
||||
mv Server-scripts/ scripts
|
||||
cd scripts
|
||||
git switch -c dev origin/dev
|
||||
git config pull.rebase true
|
||||
git config --global user.name "Lucas $(hostname | sed 's/.*/\u&/')"
|
||||
git config --global user.email lucas-f@live.at
|
||||
git config --global credential.helper store
|
||||
printf "https://lucas:<GET TOKEN>@code.someoneslinux.selfhost.eu\n" > ~/.git-credentials
|
||||
cd
|
||||
|
||||
ssh-keygen -t ed25519
|
||||
scp lucas@192.168.0.4:.ssh/authorized_keys ~/.ssh/authorized_keys
|
||||
sudo apt install vim
|
||||
vim .ssh/authorized_keys
|
||||
# Add Docker's official GPG key:
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
# Add the repository to Apt sources:
|
||||
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
|
||||
Types: deb
|
||||
URIs: https://download.docker.com/linux/ubuntu
|
||||
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
|
||||
Components: stable
|
||||
Architectures: $(dpkg --print-architecture)
|
||||
Signed-By: /etc/apt/keyrings/docker.asc
|
||||
EOF
|
||||
|
||||
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
|
||||
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
|
||||
tar xf lazygit.tar.gz lazygit
|
||||
sudo install lazygit /usr/local/bin
|
||||
|
||||
rm lazygit lazygit.tar.gz
|
||||
cat scripts/other/exports | sudo tee /etc/exports
|
||||
echo "/dev/disk/by-uuid/98695b57-1d90-484d-9347-c886c6395050 /torrent ext4 defaults 0 1" | sudo tee /etc/fstab
|
||||
sudo mkdir /torrent
|
||||
sudo systemctl daemon-reload
|
||||
sudo mount -a
|
||||
cat scripts/other/bashrc | tee ~/.bashrc
|
||||
ln -s scripts/other/bash_aliases.universal .bash_aliases
|
||||
cp scripts/other/ssh_config .ssh/config
|
||||
cat scripts/other/hosts | grep -v $(hostname) | sudo tee -a /etc/hosts > /dev/null
|
||||
cp scripts/other/lazygit_config.yml .config/lazygit/config.yml
|
||||
cp scripts/other/vimrc .vimrc
|
||||
sudo mkdir -p /opt/smartctl_exporter
|
||||
cd /tmp
|
||||
VERSION=$(curl -s https://api.github.com/repos/prometheus-community/smartctl_exporter/releases/latest | grep tag_name | cut -d '"' -f4 | sed 's/v//')
|
||||
curl -L -o smartctl_exporter.tar.gz https://github.com/prometheus-community/smartctl_exporter/releases/download/v${VERSION}/smartctl_exporter-${VERSION}.linux-amd64.tar.gz
|
||||
tar -xzf smartctl_exporter.tar.gz
|
||||
sudo cp smartctl_exporter-${VERSION}.linux-amd64/smartctl_exporter /opt/smartctl_exporter/smartctl_exporter
|
||||
sudo chmod +x /opt/smartctl-exporter/smartctl-exporter
|
||||
cd
|
||||
sudo cp scripts/services/smartctl-exporter.service /etc/systemd/system/smartctl-exporter.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now smartctl-exporter
|
||||
|
||||
cat scripts/other/smartd.conf | sed "/# $(hostname)/,/# $(hostname) end/ s/^# *//" smartd.conf | sudo tee /etc/smartd.conf
|
||||
|
||||
sudo ufw allow 9633/tcp
|
||||
sudo ufw allow 111/tcp
|
||||
sudo ufw allow 2049/tcp
|
||||
sudo ufw allow 22/tcp
|
||||
sudo ufw allow 9100/tcp
|
||||
sudo ufw enable
|
||||
|
||||
sudo chown lucas:lucas /docker/
|
||||
sudo usermod -aG docker lucas
|
||||
|
||||
(crontab -l 2>/dev/null; echo "*/5 * * * * /home/lucas/scripts/network/node-exporter-update-public-ip.sh") | crontab -
|
||||
(sudo crontab -l 2>/dev/null; echo "*/5 * * * * /home/lucas/scripts/network/node-exporter-smartmon.sh") | sudo crontab -
|
||||
|
||||
|
||||
sudo -u lucas sg docker -c '
|
||||
for d in /docker/*; do
|
||||
if [ -d "$d" ] && [ -f "$d/docker-compose.yaml" ]; then
|
||||
docker compose -f "$d/docker-compose.yaml" up -d
|
||||
fi
|
||||
done
|
||||
'
|
||||
Reference in new issue
Block a user