60 lines
1.9 KiB
Bash
Executable file
60 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Modify constants as needed
|
|
GIT_NAME="askiiart"
|
|
GIT_EMAIL="dev@askiiart.net"
|
|
KEY_ID="CFCF6723A8ED791C5FD25CB5858969DCCC2E792D"
|
|
|
|
# Note: This waits until enter is pressed
|
|
# read -p "Press Enter to continue" < /dev/tty
|
|
|
|
if [ $(whoami) == "root" ]; then
|
|
echo "Run as a normal user, not root"
|
|
exit 1
|
|
fi
|
|
|
|
command_exists() { type "$1" &>/dev/null; }
|
|
|
|
if command_exists "apt-get"; then
|
|
sudo apt-get install git -y
|
|
elif command_exists "yum"; then
|
|
sudo yum install git -y
|
|
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
|
|
sudo pacman -S git --noconfirm --needed
|
|
elif command_exists "zypp"; then
|
|
sudo zypper install git -y
|
|
elif command_exists "emerge"; then
|
|
sudo echo Not yet supported, exiting...
|
|
elif command_exists "apk"; then
|
|
sudo apk add git
|
|
elif command_exists "xbps-install"; then
|
|
sudo xbps-install git
|
|
else
|
|
echo "Unsupported: unknown package manager and distro"
|
|
fi
|
|
|
|
############################################
|
|
# Do GPG key stuff for commit verification #
|
|
############################################
|
|
git config --global user.name "${GIT_NAME}"
|
|
git config --global user.email "${GIT_EMAIL}"
|
|
git config --global commit.gpgsign true
|
|
git config --global user.signingkey ${KEY_ID}
|
|
|
|
# other git settings
|
|
git config --global init.defaultBranch main
|
|
|
|
# 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/*
|
|
# Fixes dirmngr stuff (for Arch)
|
|
sudo chmod 700 $(ls -d $HOME/.gnupg/*/)
|