Files
Misc-Scripts/add-linux-pass.sh

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
if [ -d /opt/idssys/defaults ]; then
source /opt/idssys/defaults/colors.inc
source /opt/idssys/defaults/default.inc
[ -d /opt/idssys/nodemgmt ] && source /opt/idssys/nodemgmt/defaults.inc
else
source /dev/stdin <<< "$(curl -sL http://go.scity.us/colorsinc)"
source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)"
fi
if [ "${NM_GITUSER2}" != "" ] && [ "${NM_GITPASS}" != "" ]; then
gituser=${NM_GITUSER}
gitpass=${NM_GITPASS}
else
echo -e "${idsCL[LightCyan]}You'll need to authorize yourself${idsCL[Default]}\n"
until [ "${gituser}" != "" ]; do
echo -en "${idsCL[LightCyan]}Username: ${idsCL[Default]}"
read gituser
echo
done
until [ "${gitpass}" != "" ]; do
echo -en "${idsCL[LightCyan]}Password: ${idsCL[Default]}"
read gitpass
echo
done
fi
if [ "$(curl -u "${gituser}:${gitpass}" -sL https://git.schroedercity.com/voltron/private/raw/branch/master/secret.gpg)" == "Verify" ]; then
echo -e "${idsCL[LightRed]}Authorization Failed${idsCL[Default]}\n"
exit 1
fi
echo ""
echo -e "${idsCL[LightGreen]}Adding Linux Pass Sync${idsCL[Default]}"
echo ""
apt -y install pass git curl gpg
git clone https://git.schroedercity.com/voltron/ids-linux-pass.git ~/.password-store
chmod -R 600 /root/.password-store
git config --global credential.helper store
curl -u "${gituser}:${gitpass}" -sL -o /tmp/secret.gpg https://git.schroedercity.com/voltron/private/raw/branch/master/secret.gpg
curl -u "${gituser}:${gitpass}" -sL -o /tmp/idsvc.key https://git.schroedercity.com/voltron/private/raw/branch/master/idsvc.key
gpg --import /tmp/secret.gpg
gpg --import /tmp/idsvc.key
rm -f /tmp/secret.gpg /tmp/idsvc.key
exit 0