This commit is contained in:
Bob Mottram 2018-01-11 14:23:43 +00:00
commit e3deced621
4 changed files with 95 additions and 4 deletions

View File

@ -361,15 +361,38 @@ function scuttlebot_git_setup {
fi fi
} }
function mesh_install_dat {
get_npm_arch
cat <<EOF > $rootdir/usr/bin/install_dat
#!/bin/bash
npm install --arch=$NPM_ARCH -g dat
npm install --arch=$NPM_ARCH -g @garbados/dat-boi
npm install --arch=$NPM_ARCH -g add-to-systemd
add-to-systemd dat-boi --user $(whoami) `which dat-boi`
EOF
chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
chroot "$rootdir" /usr/bin/install_dat
rm $rootdir/usr/bin/install_dat
}
function install_dat {
npm install -g dat
npm install -g @garbados/dat-boi
npm install -g add-to-systemd
add-to-systemd dat-boi --user $(whoami) `which dat-boi`
}
function mesh_install_scuttlebot { function mesh_install_scuttlebot {
SCUTTLEBOT_ONION_HOSTNAME= SCUTTLEBOT_ONION_HOSTNAME=
mesh_install_dat
get_npm_arch get_npm_arch
cat <<EOF > $rootdir/usr/bin/install_scuttlebot cat <<EOF > $rootdir/usr/bin/install_scuttlebot
#!/bin/bash #!/bin/bash
npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION} npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
npm install --arch=$NPM_ARCH -g dat
npm install --arch=$NPM_ARCH -g git-ssb npm install --arch=$NPM_ARCH -g git-ssb
npm install --arch=$NPM_ARCH -g git-remote-ssb npm install --arch=$NPM_ARCH -g git-remote-ssb
EOF EOF
@ -420,7 +443,7 @@ function install_scuttlebot {
exit 528253 exit 528253
fi fi
npm install -g dat install_dat
npm install -g git-ssb npm install -g git-ssb
npm install -g git-remote-ssb npm install -g git-remote-ssb

View File

@ -37,6 +37,19 @@ MY_EMAIL_ADDRESS=$USER@$HOSTNAME
GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//') GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
# If the default key is specified within gpg.conf
if [ -f ~/.gnupg/gpg.conf ]; then
if grep -q "default-key" ~/.gnupg/gpg.conf; then
default_gpg_key=$(cat ~/.gnupg/gpg.conf | grep "default-key")
if [[ "$default_gpg_key" != *'#'* ]]; then
default_gpg_key=$(cat ~/.gnupg/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
if [ ${#default_gpg_key} -gt 3 ]; then
GPG_ID=$(gpg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
fi
fi
fi
fi
# Start including files # Start including files
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
@ -402,8 +415,8 @@ function block_unblock_subject {
} }
function show_gpg_key { function show_gpg_key {
GPG_FINGERPRINT=$(gpg --fingerprint $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') GPG_FINGERPRINT=$(gpg --fingerprint $GPG_ID | sed -n '2p' | sed 's/^[ \t]*//')
GPG_DATE=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F ' ' '{print $3}') GPG_DATE=$(gpg --fingerprint $GPG_ID | grep -i "pub" | head -n 1 | awk -F ' ' '{print $3}')
dialog --title $"My PGP/GPG Key" \ dialog --title $"My PGP/GPG Key" \
--backtitle $"Freedombone User Control Panel" \ --backtitle $"Freedombone User Control Panel" \
--msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70 --msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
@ -415,6 +428,9 @@ function show_full_gpg_key {
echo '' echo ''
echo '' echo ''
gpg --armor --export $GPG_ID gpg --armor --export $GPG_ID
echo ''
echo ''
echo ''
gpg --armor --export-secret-key $GPG_ID gpg --armor --export-secret-key $GPG_ID
any_key any_key
} }

View File

@ -38,6 +38,19 @@ function gpg_update_mutt {
CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
# If the default key is specified within gpg.conf
if [ -f /home/$key_username/gpg.conf ]; then
if grep -q "default-key" /home/$key_username/gpg.conf; then
default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key")
if [[ "$default_gpg_key" != *'#'* ]]; then
default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
if [ ${#default_gpg_key} -gt 3 ]; then
CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
fi
fi
fi
fi
sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
@ -249,8 +262,34 @@ function gpg_pubkey_from_email {
key_id= key_id=
if [[ $key_owner_username != "root" ]]; then if [[ $key_owner_username != "root" ]]; then
key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//') key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
# If the default key is specified within gpg.conf
if [ -f /home/$key_owner_username/gpg.conf ]; then
if grep -q "default-key" /home/$key_owner_username/gpg.conf; then
default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key")
if [[ "$default_gpg_key" != *'#'* ]]; then
default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
if [ ${#default_gpg_key} -gt 3 ]; then
key_id=$(su -c "gpg --list-keys $default_gpg_key" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
fi
fi
fi
fi
else else
key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//') key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
# If the default key is specified within gpg.conf
if [ -f /root/gpg.conf ]; then
if grep -q "default-key" /root/gpg.conf; then
default_gpg_key=$(cat /root/gpg.conf | grep "default-key")
if [[ "$default_gpg_key" != *'#'* ]]; then
default_gpg_key=$(cat /root/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
if [ ${#default_gpg_key} -gt 3 ]; then
key_id=$(gpg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
fi
fi
fi
fi
fi fi
echo $key_id echo $key_id
} }

View File

@ -101,6 +101,19 @@ function interactive_gpg_from_usb {
CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
CURR_GPG_BACKUP_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//') CURR_GPG_BACKUP_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
# If the default key is specified within gpg.conf
if [ -f $HOME_DIR/gpg.conf ]; then
if grep -q "default-key" $HOME_DIR/gpg.conf; then
default_gpg_key=$(cat $HOME_DIR/gpg.conf | grep "default-key")
if [[ "$default_gpg_key" != *'#'* ]]; then
default_gpg_key=$(cat $HOME_DIR/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
if [ ${#default_gpg_key} -gt 3 ]; then
CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
fi
fi
fi
fi
echo $'Making backup copy of existing gpg keys' echo $'Making backup copy of existing gpg keys'
if [ -d $HOME_DIR/.gnupg ]; then if [ -d $HOME_DIR/.gnupg ]; then
if [ -d $HOME_DIR/.gnupg_old ]; then if [ -d $HOME_DIR/.gnupg_old ]; then