Tuesday, July 16, 2024

Shell scripts with optional parameters


while [[ $# -gt 0 ]]; do

        key="$1"

        case $key in
                -m)
                        MVN_COMMANDS=$2
                        shift # past argument
                        shift # past argument
                        ;;
                -bp)
BUILD_DIR=$2
shift
shift
;;
                -sc)
SKIP_CPP=1
shift
;;
                *)    # unknown option
                        echo Usage "$APPNAME -m \"<maven commands="">\""
                        echo "                     -bp \"<build path="">\""
                        exit 2
                        ;;
        esac
done

Sunday, July 07, 2024

GPG useful commands

List secret keys

gpg2 --list-secret-keys -v --keyid-format=long --with-subkey-fingerprints
gpg2 -K -v --keyid-format=long --with-subkey-fingerprints

List public keys

gpg2 --list-keys -v --keyid-format=long --with-subkey-fingerprints
gpg2 -k -v --keyid-format=long --with-subkey-fingerprints

Edit keys

gpg2 --edit-key xxx

Generate new key

gpg --full-generate-key

Encrypt

tar cf - tmpfile | gpg2 -u xxxx -vaser xxxx - >> tmp14.tar.gpg

tar cf tmpefile.tar tmpfile
gpg2 -u xxxx -vaser xxxx tmpefile.tar >> tmp14.tar.gpg 

gpg2 -u xxxx -o tmp14.tar.gpg -vaser xxxx tmpefile.tar

Decrypt

gpg2 -d file3.txt >> file

Show keys in a file

gpg2 -v --keyid-format=long --with-subkey-fingerprints --show-keys gpg.key

Export keys

gpg2 --export -a -o <filename>
gpg2 --export-secret-keys -a -o <filename>