# !/bin/sh THIS_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" emailre=".\+@.\+\\..\+" GPIGEON_SCRIPT=$THIS_SCRIPT_DIR/cgi-bin/gpigeon.cgi GPG_DATA_DIR='/usr/share/www-data' SCRIPT_USER='www-data' SCRIPT_GROUP=$SCRIPT_USER GPIGEON_ROOT_DIR='/var/www/gpigeon' command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" printf "Welcome to the gpigeon.cgi installer. We will first install the dependencies.\n" #apt install perl gcc make cpanminus libnet-ssleay-perl || exit 1 #cpanm Digest::SHA Email::Valid String::Random HTML::Entities CGI CGI::Carp Net::SMTP Net::SMTPS GPG || ( printf "\nInstallation of dependencies failed\n" && exit 1 ) interact() { if [ $INSTALLING eq 1 ]; then echo "already installing !" exit 1 fi printf "Choose a password for the gpigeon web application: \n" read -r -s _APP_PASSWORD while [[ $_APP_PASSWORD_VERIFICATION != $_APP_PASSWORD ]]; do printf "\nRepeat password: " read -r -s _APP_PASSWORD_VERIFICATION done # prevent obscure errors with q{} from perl _APP_PASSWORD="$(echo $_APP_PASSWORD | sed s/{/\\\\{/g | sed s/}/\\\\}/g)" HASHED_PASSWORD=`perl -e "use Digest::SHA qw(sha256_hex);print sha256_hex(q{$_APP_PASSWORD});"` printf "\nPassword matches. The SHA256 hash of it is: \033[32m$HASHED_PASSWORD\033[0m\n" printf "\nWhat is your email address: " read -r _YOUR_EMAIL while ! echo "$_YOUR_EMAIL" | grep "$emailre" >/dev/null; do printf "\nYour email address is not a valid one. Type it again: " read -r _YOUR_EMAIL done printf "\033[32m$_YOUR_EMAIL\033[0m seems a valid e-mail address." while [[ -z $_YOUR_EMAIL_PASSWORD ]]; do printf "\nPassword for your email account: " read -r -s _YOUR_EMAIL_PASSWORD done while [[ $_YOUR_EMAIL_PASSWORD_VERIFICATION != $_YOUR_EMAIL_PASSWORD ]]; do printf "\nAgain for confirmation: " read -r -s _YOUR_EMAIL_PASSWORD_VERIFICATION done _YOUR_EMAIL_PASSWORD_VERIFICATION=$(printf '%s\n' "$_YOUR_EMAIL_PASSWORD" | sed -e 's/[]\/$*.^[]/\\&/g'); domain="$(echo "$_YOUR_EMAIL" | sed "s/.*@//")" serverinfo="$(grep "^$domain" "domains.csv" 2>/dev/null)" if [ -z "$serverinfo" ]; then printf "\nAh. Your email domain isn't listed in the domains.csv file. Don't worry, you can find info relating to that easily on the domain website / the Internet, and type it in here." while ! echo "$smtp" | grep -Eo "[.[:alnum:]]"; do printf "\nWhat is the SMTP server address of your domain (typically like this: smtp.domain.net)? " read -r smtp done while ! echo "$sport" | grep -Eo "[0-9]{1,5}"; do printf "\nWhat is the SMTP server port (typically 465 or 587) ? " read -r sport done else print "Yay! Your email domain seems to be listed in domains.csv, so you don't have to manually type the smtp server address and port manually." IFS=, read service imap iport smtp sport <