Add checks for already-existing stuff, fix lots of stuff
This commit is contained in:
parent
131b2e5ec1
commit
53facd2ef7
2 changed files with 40 additions and 31 deletions
|
@ -3,14 +3,14 @@
|
||||||
set -e
|
set -e
|
||||||
# Modify constants as needed
|
# Modify constants as needed
|
||||||
GITEA_URL="https://git.askiiart.net"
|
GITEA_URL="https://git.askiiart.net"
|
||||||
REAL_NAME="askiiart"
|
NAME="askiiart"
|
||||||
EMAIL="dev@askiiart.net"
|
EMAIL="dev@askiiart.net"
|
||||||
|
|
||||||
# Note: This waits until enter is pressed
|
# Note: This waits until enter is pressed
|
||||||
# read -p "Press Enter to continue" < /dev/tty
|
# read -p "Press Enter to continue" < /dev/tty
|
||||||
|
|
||||||
if [ $(whoami) != "root" ]; then
|
if [ $(whoami) != "root" ]; then
|
||||||
$SUDO = "sudo"
|
SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "Run as a normal user, not root"
|
echo "Run as a normal user, not root"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -37,56 +37,65 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if GCM is installed
|
# 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..."
|
echo "Git Credential Manager already installed, skipping..."
|
||||||
else
|
else
|
||||||
# Install git credential manager
|
# Install git credential manager
|
||||||
curl -L https://aka.ms/gcm/linux-install-source.sh | sh
|
curl -L https://aka.ms/gcm/linux-install-source.sh | sh
|
||||||
git-credential-manager configure
|
git-credential-manager configure
|
||||||
|
rm dotnet-install.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# Do GPG key stuff for commit verification #
|
# Do GPG key stuff for commit verification #
|
||||||
############################################
|
############################################
|
||||||
|
if [ -d "${HOME}/.gnupg/" ]; then
|
||||||
|
echo "GPG key(s) already exist, skipping..."
|
||||||
|
else
|
||||||
# Create GPG key
|
# Create GPG key
|
||||||
echo "> $ gpg --full-generate-key"
|
echo "> $ gpg --full-generate-key"
|
||||||
echo Use the defaults, then real name "askiiart", email address \"dev@askiiart.net\", and comment \"git key\"\n
|
echo
|
||||||
gpg --full-generate-key
|
echo Use the defaults, then real name "askiiart", email address \"dev@askiiart.net\", and comment \"git key\"\n
|
||||||
read -p "Copy the long ID above, then paste it here: " KEY_ID
|
echo
|
||||||
echo $KEY_ID
|
gpg --full-generate-key
|
||||||
|
read -p "Copy the long ID above, then paste it here: " KEY_ID
|
||||||
|
echo $KEY_ID
|
||||||
|
|
||||||
# Export GPG key
|
# Export GPG key
|
||||||
gpg --armor --export $KEY_ID
|
gpg --armor --export $KEY_ID
|
||||||
echo This is the exported key, copy it and put it in GitHub/Gitea/whatever
|
echo This is the exported key, copy it and put it in GitHub/Gitea/whatever
|
||||||
echo Gitea URL: ${GITEA_URL}/user/settings/keys
|
echo Gitea URL: ${GITEA_URL}/user/settings/keys
|
||||||
echo GitHub URL: https://github.com/settings/gpg/new
|
echo GitHub URL: https://github.com/settings/gpg/new
|
||||||
read -p "Press enter when you're done" </dev/tty
|
read -p "Press enter when you're done" </dev/tty
|
||||||
|
pass init ${KEY_ID}
|
||||||
|
fi
|
||||||
|
|
||||||
echo Doing GCM config stuff...
|
echo Doing git config stuff...
|
||||||
git config --global credential.credentialStore gpg
|
git config --global credential.credentialStore gpg
|
||||||
pass init ${KEY_ID}
|
git config --global user.name "${NAME}"
|
||||||
|
git config --global user.email "${EMAIL}"
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# SSH stuff #
|
# SSH stuff #
|
||||||
#############
|
#############
|
||||||
|
|
||||||
# Generate SSH keys
|
|
||||||
echo
|
|
||||||
# -f: file, -N: passphrase, -t: type
|
|
||||||
ssh-keygen -f ~/.ssh/id_rsa -N "" -t rsa
|
|
||||||
|
|
||||||
# Get SSH key
|
# Get SSH key
|
||||||
echo
|
if [ -d "${HOME}/.ssh" ]; then
|
||||||
cat ~/.ssh/id_rsa.pub
|
echo "SSH keys already exist, skipping..."
|
||||||
echo This is the SSH public key, copy it and put it in GitHub/Gitea/whatever
|
else
|
||||||
echo Gitea URL: ${GITEA_URL}/user/settings/keys
|
# Generate SSH keys
|
||||||
echo GitHub URL: https://github.com/settings/ssh/new
|
echo
|
||||||
|
# -f: file, -N: passphrase, -t: type
|
||||||
echo Fixing permissions, removing temp files...
|
ssh-keygen -f ~/.ssh/id_rsa -N "" -t rsa
|
||||||
|
echo
|
||||||
|
cat ~/.ssh/id_rsa.pub
|
||||||
|
echo This is the SSH public 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/ssh/new
|
||||||
|
fi
|
||||||
|
echo Fixing permissions
|
||||||
sudo chown -R $(whoami) /home/$(whoami)/.gnupg
|
sudo chown -R $(whoami) /home/$(whoami)/.gnupg
|
||||||
sudo chgrp -R $(whoami) /home/$(whoami)/.gnupg
|
sudo chgrp -R $(whoami) /home/$(whoami)/.gnupg
|
||||||
sudo chmod -R 600 /home/$(whoami)/.gnupg
|
sudo chmod -R 600 /home/$(whoami)/.gnupg
|
||||||
rm dotnet-install.sh
|
|
||||||
|
|
||||||
read -p "Done. Now verify your SSH and GPG keys in Git*" </dev/tty
|
read -p "Done. Now verify your SSH and GPG keys in Git*" </dev/tty
|
|
@ -3,7 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ $(whoami) != "root" ]; then
|
if [ $(whoami) != "root" ]; then
|
||||||
$SUDO = "sudo"
|
SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "Run as a normal user, not root"
|
echo "Run as a normal user, not root"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue