From afdbc74b5aee3f9c7873e0c5397487f4f52afdfa Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sat, 12 Feb 2022 17:44:49 -0500 Subject: Combine init.sh and user.sh into deploy.sh --- deploy.conf | 16 --------- deploy.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ init.sh | 52 ------------------------------ user.sh | 53 ------------------------------ 4 files changed, 105 insertions(+), 121 deletions(-) delete mode 100644 deploy.conf create mode 100755 deploy.sh delete mode 100755 init.sh delete mode 100755 user.sh diff --git a/deploy.conf b/deploy.conf deleted file mode 100644 index 469d144..0000000 --- a/deploy.conf +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# -# Configuration file for deployment script - -#BACKPORTS=1 -#VM=1 -#AMDCPU=1 -#INTELCPU=1 -#AMDGPU=1 -#APTOPTS="--no-install-recommends" -#DWM=1 -#DWMBLOCKS=1 -#CONFIG_SSH=1 -#CONFIG_SSH_SERVER=1 -#CONFIG_GPG=1 - diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..0396b90 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +# Feature variables - uncomment to enable, comment to disable +#BACKPORTS=1 +#VM=1 +#AMDCPU=1 +#INTELCPU=1 +#AMDGPU=1 +#APTOPTS="--no-install-recommends" +DWM=1 +DWMBLOCKS=1 +#CONFIG_SSH=1 +#CONFIG_SSH_SERVER=1 +#CONFIG_GPG=1 + +# Change apt sources to use https +sed -i "s/http:/https:/" /etc/apt/sources.list + +[ ! -z $BACKPORTS ] && echo "deb https://deb.debian.org/debian/ bullseye-backports main" >> \ + /etc/apt/sources.list + +# Update packages +apt update -y && apt upgrade -y + +# Temporarily add contrib and non-free repos for necessary proprietary firmware and microcode +sed -i "s/main/main contrib non-free/" /etc/apt/sources.list +apt update -y + +[ ! -z $AMDCPU ] && apt install amd64-microcode -y +[ ! -z $AMDGPU ] && apt install firmware-amd-graphics -y +[ ! -z $INTELCPU ] && apt install intel-microcode -y + +# Remove contrib and non-free repos +sed -i "s/main contrib non-free/main/" /etc/apt/sources.list +apt update -y + +# Install packages +apt install $(cat packages.base) -y +apt install $(cat packages.custom) -y + +# For virtual machines + +[ ! -z $VM ] && apt install spice-vdagent xserver-xorg-video-qxl -y + +# basic configuration of ufw +ufw enable +ufw default deny incoming +ufw default allow outgoing +ufw reload + +# add user to sudo group +user=$(cat /etc/passwd | grep 1000 | cut -d ':' -f 1) +usermod -aG sudo $user + +# Change to user +su -l $user + +# lock root account +sudo passwd -l root + +# Get and deploy dotfiles +echo "backing up current home directory to ~/home_backup" +rsync -av $HOME/ $HOME/home_backup/ +cd $HOME +git clone https://git.chudnick.com/dotfiles +rsync --exclude .git/ --exclude LICENSE -av $HOME/dotfiles/ $HOME +sudo chsh -s $(which zsh) $USER + +# DWM +if [ ! -z $DWM ]; then + mkdir -p $HOME/.local/src/ + cd $HOME/.local/src/ + sudo apt install libx11-dev libx11-xcb-dev libxcb-res0-dev libxft-dev libxinerama-dev -y + git clone https://git.chudnick.com/dwm + cd dwm + sudo make install + cd $HOME +fi + +# DWMBLOCKS +if [ ! -z $DWMBLOCKS ]; then + mkdir -p $HOME/.local/src/ + cd $HOME/.local/src/ + sudo apt install libx11-dev -y + git clone https://git.chudnick.com/dwmblocks + cd dwmblocks + sudo make install + cd $HOME +fi + +# SSH +[ ! -z $CONFIG_SSH ] && ssh-keygen + +# SSH SERVER +[ ! -z $CONFIG_SSH_SERVER ] && sudo apt install openssh-server -y && sudo ufw allow ssh + +# GPG +[ ! -z $CONFIG_GPG ] && gpg --full-gen-key + +exit + +echo -e "\n\n" +echo "Next: If you chose to install dwm, logout and log back in." +echo "If you did not install dwm, you will need to install a desktop environment or window manager and then do the above" +echo -e "\n\n" diff --git a/init.sh b/init.sh deleted file mode 100755 index 50fd850..0000000 --- a/init.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Script 1 - run this as root after installation - -# source configuration file -source deploy.conf - -# Change apt sources to use https -sed -i "s/http:/https:/" /etc/apt/sources.list - -[ ! -z $BACKPORTS ] && echo "deb https://deb.debian.org/debian/ bullseye-backports main" >> \ - /etc/apt/sources.list - -# Update packages -apt update -y && apt upgrade -y - -# Temporarily add contrib and non-free repos for necessary proprietary firmware and microcode -sed -i "s/main/main contrib non-free/" /etc/apt/sources.list -apt update -y - -[ ! -z $AMDCPU ] && apt install amd64-microcode -y -[ ! -z $AMDGPU ] && apt install firmware-amd-graphics -y -[ ! -z $INTELCPU ] && apt install intel-microcode -y - -# Remove contrib and non-free repos -sed -i "s/main contrib non-free/main/" /etc/apt/sources.list -apt update -y - -# Install packages -apt install $(cat packages.base) -y -apt install $(cat packages.custom) -y - -# For virtual machines - -[ ! -z $VM ] && apt install spice-vdagent xserver-xorg-video-qxl -y - -# basic configuration of ufw -ufw enable -ufw default deny incoming -ufw default allow outgoing -ufw reload - -# add user to sudo group -user=$(cat /etc/passwd | grep 1000 | cut -d ':' -f 1) -usermod -aG sudo $user - -cp user.sh deploy.conf /home/$user/ - -echo -e "\n\n" -echo "Next: run 'logout' and then log in as the standard user created during the installation" -echo "After logging in run: './ user.sh'" -echo -e "\n\n" diff --git a/user.sh b/user.sh deleted file mode 100755 index 105610a..0000000 --- a/user.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# Script 2 - run as standard user - -# source configuration file -source deploy.conf - -# Disable root password -sudo passwd -l root - -# Get and deploy dotfiles -echo "backing up current home directory to ~/home_backup" -rsync -av $HOME/ $HOME/home_backup/ -cd $HOME -git clone https://git.chudnick.com/dotfiles -rsync --exclude .git/ --exclude LICENSE -av $HOME/dotfiles/ $HOME -chsh -s $(which zsh) $USER - -# DWM -if [ ! -z $DWM ]; then - mkdir -p $HOME/.local/src/ - cd $HOME/.local/src/ - sudo apt install libx11-dev libx11-xcb-dev libxcb-res0-dev libxft-dev libxinerama-dev -y - git clone https://git.chudnick.com/dwm - cd dwm - sudo make install - cd $HOME -fi - -# DWMBLOCKS -if [ ! -z $DWMBLOCKS ]; then - mkdir -p $HOME/.local/src/ - cd $HOME/.local/src/ - sudo apt install libx11-dev -y - git clone https://git.chudnick.com/dwmblocks - cd dwmblocks - sudo make install - cd $HOME -fi - -# SSH -[ ! -z $CONFIG_SSH ] && ssh-keygen - -# SSH SERVER -[ ! -z $CONFIG_SSH_SERVER ] && sudo apt install openssh-server -y && sudo ufw allow ssh - -# GPG -[ ! -z $CONFIG_GPG ] && gpg --full-gen-key - -echo -e "\n\n" -echo "Next: If you chose to install dwm, logout and log back in." -echo "If you did not install dwm, you will need to install a desktop environment or window manager and then do the above" -echo -e "\n\n" -- cgit v1.2.3