2023-08-21 10:59:54 -05:00
|
|
|
#!/bin/bash
|
2023-08-21 13:13:13 -05:00
|
|
|
# Exit if there's an error
|
|
|
|
set -e
|
2023-08-20 21:35:16 -05:00
|
|
|
# Modify constants as needed
|
2023-08-21 12:02:10 -05:00
|
|
|
GITEA_URL="https://git.askiiart.net"
|
|
|
|
REAL_NAME="askiiart"
|
|
|
|
EMAIL="dev@askiiart.net"
|
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-08-20 21:35:16 -05:00
|
|
|
declare -A osInfo;
|
|
|
|
osInfo[/etc/redhat-release]=yum
|
|
|
|
osInfo[/etc/arch-release]=pacman
|
|
|
|
osInfo[/etc/gentoo-release]=emerge
|
|
|
|
osInfo[/etc/SuSE-release]=zypp
|
|
|
|
osInfo[/etc/debian_version]=apt-get
|
|
|
|
osInfo[/etc/alpine-release]=apk
|
|
|
|
|
2023-08-21 10:59:54 -05:00
|
|
|
for f in ${!osInfo[@]}
|
2023-08-20 21:35:16 -05:00
|
|
|
do
|
2023-08-21 10:59:54 -05:00
|
|
|
if [[ -f $f ]];then
|
2023-08-21 19:04:55 -05:00
|
|
|
PACKAGE_MANAGER=${osInfo[$f]}
|
2023-08-20 21:35:16 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-08-21 19:04:55 -05:00
|
|
|
sudo ${PACKAGE_MANAGER} install pass git -y
|
2023-08-19 17:04:13 -05:00
|
|
|
|
2023-08-21 22:08:51 -05:00
|
|
|
# Check if GCM is installed
|
|
|
|
if [ -f "${HOME}/.git-credentials" ]; then
|
|
|
|
echo "Git Credential Manager already installed, skipping..."
|
|
|
|
else
|
|
|
|
# Install git credential manager
|
|
|
|
curl -L https://aka.ms/gcm/linux-install-source.sh | sh
|
|
|
|
git-credential-manager configure
|
|
|
|
fi
|
2023-08-19 17:04:13 -05:00
|
|
|
|
|
|
|
############################################
|
|
|
|
# Do GPG key stuff for commit verification #
|
|
|
|
############################################
|
|
|
|
|
|
|
|
# Create GPG key
|
|
|
|
echo "> $ gpg --full-generate-key"
|
|
|
|
echo Use the defaults, then real name "askiiart", email address \"dev@askiiart.net\", and comment \"git key\"\n
|
|
|
|
gpg --full-generate-key
|
|
|
|
read -p "Copy the long ID above, then paste it here: " KEY_ID
|
|
|
|
echo $KEY_ID
|
|
|
|
|
|
|
|
# Export GPG key
|
|
|
|
gpg --armor --export $KEY_ID
|
2023-08-20 21:35:16 -05:00
|
|
|
echo This is the exported key, copy it and put it in GitHub/Gitea/whatever
|
|
|
|
echo Gitea URL: ${GITEA_URL}/user/settings/keys
|
2023-08-19 17:04:13 -05:00
|
|
|
echo GitHub URL: https://github.com/settings/gpg/new
|
|
|
|
read -p "Press enter when you're done" < /dev/tty
|
2023-08-21 12:02:10 -05:00
|
|
|
|
2023-08-21 12:06:09 -05:00
|
|
|
echo Doing GCM config stuff...
|
|
|
|
git config --global credential.credentialStore gpg
|
|
|
|
pass init ${KEY_ID}
|
|
|
|
|
2023-08-19 17:04:13 -05:00
|
|
|
#############
|
|
|
|
# SSH stuff #
|
|
|
|
#############
|
|
|
|
|
|
|
|
# Generate SSH keys
|
|
|
|
echo
|
|
|
|
# -f: file, -N: passphrase, -t: type
|
|
|
|
ssh-keygen -f ~/.ssh/id_rsa -N "" -t rsa
|
|
|
|
|
|
|
|
# Get SSH key
|
|
|
|
echo
|
|
|
|
cat ~/.ssh/id_rsa.pub
|
2023-08-20 21:35:16 -05:00
|
|
|
echo This is the SSH public key, copy it and put it in GitHub/Gitea/whatever
|
|
|
|
echo Gitea URL: ${GITEA_URL}/user/settings/keys
|
2023-08-19 17:04:13 -05:00
|
|
|
echo GitHub URL: https://github.com/settings/ssh/new
|
|
|
|
|
2023-08-19 17:06:40 -05:00
|
|
|
echo Fixing permissions, removing temp files...
|
|
|
|
sudo chown -R $(whoami) /home/$(whoami)/.gnupg
|
|
|
|
sudo chgrp -R $(whoami) /home/$(whoami)/.gnupg
|
|
|
|
sudo chmod -R 700 /home/$(whoami)/.gnupg
|
|
|
|
rm dotnet-install.sh
|
|
|
|
|
2023-08-19 17:04:13 -05:00
|
|
|
read -p "Done. Now verify your SSH and GPG keys in Git*" < /dev/tty
|