1
0
Fork 0

pratham-setup:

- check if pratham is in sudoers first
 - fix typo in generating ssh keys
 - merge two rsyncs into one
 - modify yay installation since I only need it for ZFS
 - add steps to notify user about what the script can't do itself
This commit is contained in:
Pratham Patel 2022-11-20 22:43:51 +05:30
parent df2354920c
commit 5aea7a13ec
1 changed files with 47 additions and 34 deletions

View File

@ -5,7 +5,13 @@
################################################################################ ################################################################################
# for visudo # for visudo
EDITOR=/usr/bin/vim EDITOR=/usr/bin/nvim
# setup sudo access for pratham
/usr/bin/sudo -l -U pratham >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
doas visudo
fi
# set hostname # set hostname
WHAT_IS_MY_HOSTNAME=$(cat /etc/hostname) WHAT_IS_MY_HOSTNAME=$(cat /etc/hostname)
@ -43,7 +49,7 @@ fi
function generate_keys() function generate_keys()
{ {
if [[ ! -f "$1" && ! -f "$1"".pub" ]]; then if [[ ! -f "$1" && ! -f "$1"".pub" ]]; then
ssh-keygen -f ed25519 -f $1 ssh-keygen -t ed25519 -f $1
fi fi
} }
@ -91,7 +97,7 @@ Host git.thefossguy.com
Port 22 Port 22
EOF EOF
cat $HOME/.ssh/gitea.pub cat $HOME/.ssh/gitea.pub
echo "Populate Hostname (IP addr) for \"git.thefossguy.com\" in ~/.ssh/config" echo -e "\n\n\n\nPopulate Hostname (IP addr) for \"git.thefossguy.com\" in ~/.ssh/config"
bash bash
fi fi
@ -108,7 +114,6 @@ function git_repo_check()
git clone git@git.thefossguy.com:thefossguy/"$1" git clone git@git.thefossguy.com:thefossguy/"$1"
else else
pushd "$1" pushd "$1"
tput -x clear
git fetch git fetch
git pull git pull
popd popd
@ -139,51 +144,57 @@ rsync \
--progress --stats \ --progress --stats \
--itemize-changes --checksum \ --itemize-changes --checksum \
--exclude=".git" --exclude=".gitignore" --exclude="README.md" \ --exclude=".git" --exclude=".gitignore" --exclude="README.md" \
~/my-git-repos/dotfiles/ ~/ ~/my-git-repos/dotfiles{,-priv}/ ~/
rsync \
--verbose --recursive --size-only --human-readable \
--progress --stats \
--itemize-changes --checksum \
--exclude=".git" --exclude=".gitignore" \
~/my-git-repos/dotfiles-priv/ ~/
# podman? # podman?
#grep net.ipv4.ping_group_range /etc/sysctl.conf || echo "net.ipv4.ping_group_range=0 $(grep pratham /etc/subuid | awk -F ":" '{print $2 + $3}')" | doas tee -a /etc/sysctl.conf #grep net.ipv4.ping_group_range /etc/sysctl.conf || echo "net.ipv4.ping_group_range=0 $(grep pratham /etc/subuid | awk -F ":" '{print $2 + $3}')" | doas tee -a /etc/sysctl.conf
################################################################################ ################################################################################
# AUR-RELATED # AUR-RELATED/ZFS
################################################################################ ################################################################################
# setup sudo access for pratham (required for makepkg) # first, check if ZFS is already installed or not
/usr/bin/sudo -l -U pratham >/dev/null 2>&1 pacman -Qm | grep "zfs-dkms"
if [[ $? -ne 0 ]]; then if [[ $? -eq 0 ]]; then
doas visudo ZFS_Y_OR_N=n
else
echo "Do you want to install ZFS, and by extension, \`yay\`? (y/n)"
read ZFS_Y_OR_N
fi fi
# build yay
if command -v yay >/dev/null; then
echo "yay is already installed"
else
# install necessary packages for installing \`yay\`
doas pacman --sync --refresh --needed base-devel
git clone --depth 1 https://aur.archlinux.org/yay-bin.git /tmp/yay-tmp-clone # build yay as the AUR helper that installs the `zfs-dkms` AUR package
pushd /tmp/yay-tmp-clone if [[ $ZFS_Y_OR_N == "y" || $ZFS_Y_OR_N == "Y" ]]; then
makepkg -si # do I have yay?
if [[ $? -ne 0 ]]; then if ! command -v yay > /dev/null; then
echo "yay wasn't installed successfully :("
exit 1 # build yay
doas pacman --sync --refresh --refresh --sysupgrade
doas pacman --needed base-devel
git clone --depth 1 https://aur.archlinux.org/yay-bin.git /tmp/yay-tmp-clone
pushd /tmp/yay-tmp-clone
makepkg -si --needed
if [[ $? -ne 0 ]]; then
echo "yay wasn't installed successfully :("
exit 1
else
yay -Y --gendb
yay -Syu --devel
fi
popd
fi fi
popd # install ZFS DKMS
yay -S zfs-dkms
fi fi
# AUR pkgs # AUR pkgs
yay -S noisetorch ssmtp #yay -S noisetorch ssmtp
#yay -S zfs-dkms
# wayland-WM # wayland-WM
#yay -S hyperland #yay -S hyperland
@ -196,5 +207,7 @@ yay -S noisetorch ssmtp
# WRAP UP # WRAP UP
################################################################################ ################################################################################
tput -x clear echo -e "\n\nThe setup appears to have completed (as far as I can tell). Please scroll up and verify yourself too!"
echo "vim-plug for nvim has been installed, please fetch the plugins using the \':PlugInstall\` command" echo -e "\nBelow are a few items I can not script myself:\n"
echo -e "\n=> please run the \`:PlugInstall\` command in nvim (aliased to vim now)"
echo -e "\n=> please uncomment the line that says $(tput bold)- ~/.config/alacritty/load_linux.yml$(tput sgr0)"