configs/daily-use-pcs/setup-git.bash

61 lines
1.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2023-08-20 21:35:16 -05:00
# Modify constants as needed
2023-09-13 07:58:18 -05:00
GIT_NAME="askiiart"
GIT_EMAIL="dev@askiiart.net"
KEY_ID="CFCF6723A8ED791C5FD25CB5858969DCCC2E792D"
2023-08-20 21:35:16 -05:00
# Note: This waits until enter is pressed
2023-08-19 17:04:13 -05:00
# read -p "Press Enter to continue" < /dev/tty
2023-09-06 15:18:40 -05:00
if [ $(whoami) == "root" ]; then
2023-08-30 22:15:13 -05:00
echo "Run as a normal user, not root"
exit 1
fi
command_exists() { type "$1" &>/dev/null; }
if command_exists "apt-get"; then
2024-03-17 18:56:48 -05:00
sudo apt-get install git -y
elif command_exists "yum"; then
2024-03-17 18:56:48 -05:00
sudo yum install git -y
2024-07-10 13:21:06 -05:00
elif command_exists "rpm-ostree" && ! command_exists "git"; then
rpm-ostree install git -y
read -p "Press enter to reboot, then run do-everything.bash again"
reboot
elif command_exists "pacman"; then
2023-09-07 09:13:31 -05:00
sudo pacman -S git --noconfirm --needed
elif command_exists "zypp"; then
2024-03-17 18:56:48 -05:00
sudo zypper install git -y
elif command_exists "emerge"; then
2023-09-06 15:18:40 -05:00
sudo echo Not yet supported, exiting...
elif command_exists "apk"; then
2023-09-06 15:18:40 -05:00
sudo apk add git
2024-04-20 20:35:22 -05:00
elif command_exists "xbps-install"; then
sudo xbps-install git
else
echo "Unsupported: unknown package manager and distro"
fi
2023-08-19 17:04:13 -05:00
############################################
# Do GPG key stuff for commit verification #
############################################
2023-09-13 08:23:45 -05:00
git config --global user.name "${GIT_NAME}"
git config --global user.email "${GIT_EMAIL}"
2023-10-10 13:27:57 -05:00
git config --global commit.gpgsign true
git config --global user.signingkey ${KEY_ID}
2023-09-01 06:58:35 -05:00
# other git settings
git config --global init.defaultBranch main
2023-09-01 06:58:35 -05:00
# From https://superuser.com/a/954639
# Archived at https://web.archive.org/web/20230606153856/https://superuser.com/a/954639
echo Fixing .gnupg/ permissions
# Set ownership to your own user and primary group
chown -R "$USER:$(id -gn)" ~/.gnupg
# Set permissions to read, write, execute for only yourself, no others
chmod 700 ~/.gnupg
# Set permissions to read, write for only yourself, no others
chmod 600 ~/.gnupg/*
2024-03-17 18:56:48 -05:00
# Fixes dirmngr stuff (for Arch)
2023-09-07 16:34:26 -05:00
sudo chmod 700 $(ls -d $HOME/.gnupg/*/)