From 53facd2ef787790861c6f3ef59d809f907dd9af7 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 31 Aug 2023 10:28:37 -0500 Subject: [PATCH 1/2] Add checks for already-existing stuff, fix lots of stuff --- daily-use-pcs/{fedora => }/setup-git.bash | 69 +++++++++++++---------- zsh/zsh-setup.bash | 2 +- 2 files changed, 40 insertions(+), 31 deletions(-) rename daily-use-pcs/{fedora => }/setup-git.bash (54%) diff --git a/daily-use-pcs/fedora/setup-git.bash b/daily-use-pcs/setup-git.bash similarity index 54% rename from daily-use-pcs/fedora/setup-git.bash rename to daily-use-pcs/setup-git.bash index 4b97b60..22e19a2 100755 --- a/daily-use-pcs/fedora/setup-git.bash +++ b/daily-use-pcs/setup-git.bash @@ -3,14 +3,14 @@ set -e # Modify constants as needed GITEA_URL="https://git.askiiart.net" -REAL_NAME="askiiart" +NAME="askiiart" EMAIL="dev@askiiart.net" # Note: This waits until enter is pressed # read -p "Press Enter to continue" < /dev/tty if [ $(whoami) != "root" ]; then - $SUDO = "sudo" + SUDO="sudo" else echo "Run as a normal user, not root" exit 1 @@ -37,56 +37,65 @@ else fi # Check if GCM is installed -if [ -f "${HOME}/.git-credentials" ]; then +if [ -d "${HOME}/git-credential-manager" ]; 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 + rm dotnet-install.sh fi ############################################ # Do GPG key stuff for commit verification # ############################################ - +if [ -d "${HOME}/.gnupg/" ]; then + echo "GPG key(s) already exist, skipping..." +else # 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 + echo "> $ gpg --full-generate-key" + echo + echo Use the defaults, then real name "askiiart", email address \"dev@askiiart.net\", and comment \"git key\"\n + echo + 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 -echo This is the exported key, copy it and put it in GitHub/Gitea/whatever -echo Gitea URL: ${GITEA_URL}/user/settings/keys -echo GitHub URL: https://github.com/settings/gpg/new -read -p "Press enter when you're done" Date: Fri, 1 Sep 2023 06:58:35 -0500 Subject: [PATCH 2/2] *Actually* fix gnupg perms --- daily-use-pcs/setup-git.bash | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/daily-use-pcs/setup-git.bash b/daily-use-pcs/setup-git.bash index 22e19a2..d4e5804 100755 --- a/daily-use-pcs/setup-git.bash +++ b/daily-use-pcs/setup-git.bash @@ -93,9 +93,15 @@ else echo Gitea URL: ${GITEA_URL}/user/settings/keys echo GitHub URL: https://github.com/settings/ssh/new fi -echo Fixing permissions -sudo chown -R $(whoami) /home/$(whoami)/.gnupg -sudo chgrp -R $(whoami) /home/$(whoami)/.gnupg -sudo chmod -R 600 /home/$(whoami)/.gnupg + +# 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/* read -p "Done. Now verify your SSH and GPG keys in Git*"