Standardise password lengths

This commit is contained in:
Bob Mottram 2016-06-04 14:25:46 +01:00
parent f460e0c033
commit 152360ab96
8 changed files with 223 additions and 165 deletions

View File

@ -6188,7 +6188,7 @@ function install_mariadb {
if [ -f $IMAGE_PASSWORD_FILE ]; then
MARIADB_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
MARIADB_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
MARIADB_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
echo "$MARIADB_PASSWORD" > $DATABASE_PASSWORD_FILE
chmod 600 $DATABASE_PASSWORD_FILE
@ -6547,7 +6547,7 @@ function install_gogs {
if [ -f $IMAGE_PASSWORD_FILE ]; then
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
GIT_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
GIT_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
@ -6742,7 +6742,7 @@ function install_gogs {
if grep -q "Gogs secret key:" /home/$MY_USERNAME/README; then
GOGS_SECRET_KEY=$(cat /home/$MY_USERNAME/README | grep "Gogs secret key:" | awk -F ':' '{print $2}' | sed 's/^ *//')
else
GOGS_SECRET_KEY="$(openssl rand -base64 20 | cut -c1-18)"
GOGS_SECRET_KEY="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
echo "Gogs secret key:$GOGS_SECRET_KEY" >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
fi
@ -7134,7 +7134,7 @@ function install_xmpp {
if [ -f $IMAGE_PASSWORD_FILE ]; then
XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
XMPP_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
XMPP_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
@ -7347,7 +7347,7 @@ function install_irc_server {
# create a login password if needed
if [ ! $IRC_PASSWORD ]; then
IRC_PASSWORD="$(openssl rand -base64 32 | cut -c1-10)"
IRC_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
echo '**************************************************' > /etc/ngircd/motd
@ -7374,7 +7374,7 @@ function install_irc_server {
if [ -f $IMAGE_PASSWORD_FILE ]; then
IRC_OPERATOR_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
IRC_OPERATOR_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
IRC_OPERATOR_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
sed -i "s|;CloakHostSalt = abcdefghijklmnopqrstuvwxyz|CloakHostSalt = $IRC_SALT|g" /etc/ngircd/ngircd.conf
sed -i 's/;ConnectIPv4 = yes/ConnectIPv4 = yes/g' /etc/ngircd/ngircd.conf
@ -7512,7 +7512,7 @@ function install_wiki {
if [ -f $IMAGE_PASSWORD_FILE ]; then
WIKI_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
WIKI_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
WIKI_ADMIN_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
HASHED_WIKI_PASSWORD=$(echo -n "$WIKI_ADMIN_PASSWORD" | md5sum | awk -F ' ' '{print $1}')
@ -8117,7 +8117,7 @@ function install_blog {
if [ -f $IMAGE_PASSWORD_FILE ]; then
FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
FULLBLOG_ADMIN_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
@ -8203,7 +8203,7 @@ function install_rss_reader {
if [ -f $IMAGE_PASSWORD_FILE ]; then
RSS_READER_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
RSS_READER_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
@ -8573,7 +8573,7 @@ function install_gnu_social {
if [ -f $IMAGE_PASSWORD_FILE ]; then
MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
MICROBLOG_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
@ -9278,7 +9278,7 @@ function install_search_engine {
if [ -f $IMAGE_PASSWORD_FILE ]; then
SEARCH_ENGINE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
SEARCH_ENGINE_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
echo "$SEARCH_ENGINE_PASSWORD" | htpasswd -i -s -c /etc/nginx/.htpasswd $MY_USERNAME
@ -9347,7 +9347,7 @@ function install_webmail {
if [ -f $IMAGE_PASSWORD_FILE ]; then
WEBMAIL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
WEBMAIL_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
WEBMAIL_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
create_database webmail "$WEBMAIL_ADMIN_PASSWORD"
@ -9513,7 +9513,7 @@ function install_hubzilla {
if [ -f $IMAGE_PASSWORD_FILE ]; then
HUBZILLA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-30)"
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
@ -10645,9 +10645,9 @@ function install_voip {
if [ -f $IMAGE_PASSWORD_FILE ]; then
VOIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
VOIP_SERVER_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
VOIP_SERVER_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
if [ ${#VOIP_SERVER_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
VOIP_SERVER_PASSWORD="$(openssl rand -base64 18 | cut -c1-16)"
VOIP_SERVER_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi
fi
@ -10778,7 +10778,7 @@ function install_sip {
if [ -f $IMAGE_PASSWORD_FILE ]; then
SIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
SIP_SERVER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
SIP_SERVER_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
fi

View File

@ -61,7 +61,17 @@ if [ ! -f $COMPLETION_FILE ]; then
exit 3
fi
NEW_USER_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
NEW_USER_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
useradd -m -p "$NEW_USER_PASSWORD" -s /bin/bash $MY_USERNAME
adduser $MY_USERNAME sasl

View File

@ -44,6 +44,13 @@ FREEDOMBONE_WEBSITE="http://freedombone.uk.to"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
# file containing new password
IMAGE_PASSWORD_FILE=/root/login.txt
@ -849,7 +856,7 @@ function interactive_configuration {
if [ ! $WIFI_SSID ]; then
WIFI_SSID='mesh'
fi
#data=$(tempfile 2>/dev/null)
#trap "rm -f $data" 0 1 2 5 15
#dialog --backtitle "Freedombone Configuration" \
@ -1073,7 +1080,7 @@ function interactive_configuration {
done
save_configuration_file
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
if [[ $(grep "INSTALLING_ON_BBB" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
dialog --title $"Install Target" \
@ -1351,11 +1358,11 @@ function interactive_configuration {
NAMESERVER1='85.214.73.63'
NAMESERVER2='213.73.91.35'
fi
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
${PROJECT_NAME}-wifi --networksinteractive $WIFI_NETWORKS_FILE
fi
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" && $ONION_ONLY == "no" ]]; then
data=$(tempfile 2>/dev/null)
@ -1675,7 +1682,7 @@ function interactive_configuration {
save_configuration_file
fi
fi
if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
if [[ $ONION_ONLY != "no" ]]; then

View File

@ -41,7 +41,14 @@ UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
UPDATE_DATE_SCRIPT=/usr/bin/updatedate
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=8
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
# voip
VOIP_PORT=64738
@ -143,7 +150,7 @@ function check_for_updates {
}
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_SERVER=$(grep "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
@ -523,7 +530,7 @@ function smtp_proxy {
if [ ! -f $MUTTRC_FILE ]; then
return
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
@ -554,7 +561,7 @@ function smtp_proxy {
echo "set smtp_url=\"${SMTP_PROXY_PROTOCOL}://${SMTP_PROXY_USERNAME}:${SMTP_PROXY_PASSWORD}@${SMTP_PROXY_SERVER}:${SMTP_PROXY_PORT}/\"" >> $MUTTRC_FILE
else
sed -i "s|set smtp_url=.*|set smtp_url=\"${SMTP_PROXY_PROTOCOL}://${SMTP_PROXY_USERNAME}:${SMTP_PROXY_PASSWORD}@${SMTP_PROXY_SERVER}:${SMTP_PROXY_PORT}/\"|g" $MUTTRC_FILE
fi
fi
sed -i 's|#set smtp_url|set smtp_url|g' $MUTTRC_FILE
else
if grep "set smtp_url" $MUTTRC_FILE; then
@ -678,13 +685,13 @@ function irc_set_global_password {
if [ -f /home/$IRC_USERNAME/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/$IRC_USERNAME/.irssi/config
chown -R $IRC_USERNAME:$IRC_USERNAME /home/$IRC_USERNAME/.irssi
fi
fi
fi
done
# restart the daemon for the new password to take effect
systemctl restart ngircd
dialog --title $"IRC Password" \
--msgbox $"The IRC password was changed" 6 40
;;
@ -708,7 +715,7 @@ function change_blog_avatar {
dialog --title $"Change blog avatar" \
--msgbox $"Your blog avatar has been changed" 6 40
fi
fi
fi
;;
esac
}
@ -1737,7 +1744,7 @@ function hotspot_settings {
esac
TEMP_WIFI_HOTSPOT=$(cat $data | sed -n 1p)
TEMP_WIFI_SSID=$(cat $data | sed -n 2p)
TEMP_WIFI_TYPE=$(cat $data | sed -n 3p)
TEMP_WIFI_TYPE=$(cat $data | sed -n 3p)
TEMP_WIFI_PASSPHRASE=$(cat $data | sed -n 4p)
if [ ${#TEMP_WIFI_SSID} -lt 2 ]; then
@ -1768,19 +1775,19 @@ function hotspot_settings {
--msgbox $"Wifi hotspot passphrase was too short" 6 40
return
fi
WIFI_HOTSPOT=$TEMP_WIFI_HOTSPOT
WIFI_SSID=$TEMP_WIFI_SSID
WIFI_TYPE=$TEMP_WIFI_TYPE
WIFI_PASSPHRASE=$TEMP_WIFI_PASSPHRASE
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $WIFI_HOTSPOT $WIFI_EXTRA
else
WIFI_HOTSPOT=$TEMP_WIFI_HOTSPOT
WIFI_SSID=$TEMP_WIFI_SSID
WIFI_TYPE=$TEMP_WIFI_TYPE
WIFI_PASSPHRASE=$TEMP_WIFI_PASSPHRASE
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $WIFI_HOTSPOT $WIFI_EXTRA
fi
@ -1805,7 +1812,7 @@ function hotspot_settings {
else
sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=$WIFI_PASSPHRASE|g" $CONFIGURATION_FILE
fi
dialog --title $"Wifi Settings" \
--msgbox $"Hotspot settings were changed" 6 40
}
@ -1970,7 +1977,7 @@ function wifi_enable {
${PROJECT_NAME}-wifi --disable $disable_wifi
}
function menu_wifi {
function menu_wifi {
while true
do
status_str=$'Wifi OFF'
@ -1979,9 +1986,9 @@ function menu_wifi {
else
if grep -q "# wifi enabled" /etc/network/interfaces; then
status_str=$'Wifi ON'
fi
fi
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
@ -2013,7 +2020,7 @@ function menu_irc {
--msgbox $"No IRC server is installed" 6 70
return
fi
while true
do
data=$(tempfile 2>/dev/null)

View File

@ -77,6 +77,13 @@ DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
# Optional ssh public key to allow
SSH_PUBKEY="no"
@ -287,7 +294,7 @@ fi
if [ ! $PASSWORD ]; then
# generate a random password
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
fi
# Move any existing images into a build subdirectory

View File

@ -49,6 +49,16 @@ MINIMAL_INSTALL="yes"
MY_USERNAME='debian'
MY_PASSWORD="${PROJECT_NAME}"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
# IP address of the router (gateway)
ROUTER_IP_ADDRESS="192.168.1.254"
@ -283,7 +293,8 @@ EOF
echo " dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50" >> $rootdir/root/.bashrc
echo ' exit' >> $rootdir/root/.bashrc
echo ' fi' >> $rootdir/root/.bashrc
echo ' NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"' >> $rootdir/root/.bashrc
echo -n ' NEW_USER_PASSWORD="$(openssl rand -base64 30 | cut -c1-' >> $rootdir/root/.bashrc
echo "${MINIMUM_PASSWORD_LENGTH})\"" >> $rootdir/root/.bashrc
echo ' fi' >> $rootdir/root/.bashrc
echo ' echo "${NEW_USER_PASSWORD}" > ~/login.txt' >> $rootdir/root/.bashrc

View File

@ -35,6 +35,13 @@ export TEXTDOMAINDIR="/usr/share/locale"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"

View File

@ -35,6 +35,8 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-remote
export TEXTDOMAINDIR="/usr/share/locale"
CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
# User to create the list for
MY_USERNAME=$USER
@ -42,7 +44,14 @@ MY_USERNAME=$USER
FRIENDS_SERVERS_LIST=
# Minimum password length in characters
MINIMUM_PASSWORD_LENGTH=8
MINIMUM_PASSWORD_LENGTH=10
if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/local/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
else
if [ -f /usr/bin/${PROJECT_NAME} ]; then
MINIMUM_PASSWORD_LENGTH=$(cat /usr/bin/${PROJECT_NAME} | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
fi
fi
# How many remote locations were specified
entering_remote_backups_ctr=0
@ -78,61 +87,61 @@ do
key="$1"
case $key in
-h|--help)
show_help
;;
# backup list filename
# typically /home/$USER/backup.list
-l|--list)
shift
FRIENDS_SERVERS_LIST="$1"
;;
# username within /home
-u|--user)
shift
MY_USERNAME="$1"
;;
# Minimum password length
-m|--min)
shift
MINIMUM_PASSWORD_LENGTH="$1"
;;
# Title shown
-t|--title)
shift
TITLE="$1"
;;
# reciprocal user accounts
-r|--reciprocal)
shift
RECIPROCAL="yes"
;;
*)
# unknown option
;;
-h|--help)
show_help
;;
# backup list filename
# typically /home/$USER/backup.list
-l|--list)
shift
FRIENDS_SERVERS_LIST="$1"
;;
# username within /home
-u|--user)
shift
MY_USERNAME="$1"
;;
# Minimum password length
-m|--min)
shift
MINIMUM_PASSWORD_LENGTH="$1"
;;
# Title shown
-t|--title)
shift
TITLE="$1"
;;
# reciprocal user accounts
-r|--reciprocal)
shift
RECIPROCAL="yes"
;;
*)
# unknown option
;;
esac
shift
done
function interactive_configuration_remote_backups {
if [ ! $MY_USERNAME ]; then
echo $'Please specify a username with the -u option'
exit 7356
echo $'Please specify a username with the -u option'
exit 7356
fi
if [ ! /home/$MY_USERNAME ]; then
echo $"The user /home/$MY_USERNAME does not exist on the system"
exit 3689
echo $"The user /home/$MY_USERNAME does not exist on the system"
exit 3689
fi
if [ ! $FRIENDS_SERVERS_LIST ]; then
FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
fi
# clear any existing list
if [ -f $FRIENDS_SERVERS_LIST ]; then
rm -f $FRIENDS_SERVERS_LIST
touch $FRIENDS_SERVERS_LIST
rm -f $FRIENDS_SERVERS_LIST
touch $FRIENDS_SERVERS_LIST
fi
# number of entries made
entering_remote_backups_ctr=1
@ -146,103 +155,103 @@ function interactive_configuration_remote_backups {
remote_ssh_reciprocal_password=""
while [[ $entering_remote_backups_done == "no" ]]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $RECIPROCAL == "yes" ]]; then
dialog --backtitle "Freedombone Configuration" \
--title "$TITLE ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details for the remote server\n\nThe reciprocal entries are optional, and can be used if you wish to set up a user account on this system for whoever runs the remote server to also use for backups" 20 50 8 \
"Username:" 1 1 "$remote_ssh_username" 1 23 16 15 \
"Domain:" 2 1 "$remote_ssh_domain" 2 23 16 15 \
"SSH port:" 3 1 "2222" 3 23 5 4 \
"Password:" 4 1 "$remote_ssh_password" 4 23 20 100 \
"Reciprocal Username:" 5 1 "$remote_ssh_reciprocal_username" 5 23 20 100 \
"Reciprocal Password:" 6 1 "$remote_ssh_reciprocal_password" 6 23 20 100 \
2> $data
else
dialog --backtitle "Freedombone Configuration" \
--title "$TITLE ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details for the remote server" 15 50 4 \
"Username:" 1 1 "$remote_ssh_username" 1 23 16 15 \
"Domain:" 2 1 "$remote_ssh_domain" 2 23 16 15 \
"SSH port:" 3 1 "2222" 3 23 5 4 \
"Password:" 4 1 "$remote_ssh_password" 4 23 20 100 \
2> $data
fi
sel=$?
case $sel in
1) entering_remote_backups_done="yes";;
255) entering_remote_backups_done="yes";;
esac
remote_ssh_username=$(cat $data | sed -n 1p)
remote_ssh_domain=$(cat $data | sed -n 2p)
remote_ssh_port=$(cat $data | sed -n 3p)
remote_ssh_password=$(cat $data | sed -n 4p)
remote_ssh_reciprocal_username=$(cat $data | sed -n 5p)
remote_ssh_reciprocal_password=$(cat $data | sed -n 6p)
if [[ $remote_ssh_username != "" && \
$remote_ssh_domain != "" && \
$remote_ssh_port != "" && \
$remote_ssh_password != "" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $RECIPROCAL == "yes" ]]; then
dialog --backtitle "Freedombone Configuration" \
--title "$TITLE ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details for the remote server\n\nThe reciprocal entries are optional, and can be used if you wish to set up a user account on this system for whoever runs the remote server to also use for backups" 20 50 8 \
"Username:" 1 1 "$remote_ssh_username" 1 23 16 15 \
"Domain:" 2 1 "$remote_ssh_domain" 2 23 16 15 \
"SSH port:" 3 1 "2222" 3 23 5 4 \
"Password:" 4 1 "$remote_ssh_password" 4 23 20 100 \
"Reciprocal Username:" 5 1 "$remote_ssh_reciprocal_username" 5 23 20 100 \
"Reciprocal Password:" 6 1 "$remote_ssh_reciprocal_password" 6 23 20 100 \
2> $data
else
dialog --backtitle "Freedombone Configuration" \
--title "$TITLE ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details for the remote server" 15 50 4 \
"Username:" 1 1 "$remote_ssh_username" 1 23 16 15 \
"Domain:" 2 1 "$remote_ssh_domain" 2 23 16 15 \
"SSH port:" 3 1 "2222" 3 23 5 4 \
"Password:" 4 1 "$remote_ssh_password" 4 23 20 100 \
2> $data
fi
sel=$?
case $sel in
1) entering_remote_backups_done="yes";;
255) entering_remote_backups_done="yes";;
esac
remote_ssh_username=$(cat $data | sed -n 1p)
remote_ssh_domain=$(cat $data | sed -n 2p)
remote_ssh_port=$(cat $data | sed -n 3p)
remote_ssh_password=$(cat $data | sed -n 4p)
remote_ssh_reciprocal_username=$(cat $data | sed -n 5p)
remote_ssh_reciprocal_password=$(cat $data | sed -n 6p)
if [[ $remote_ssh_username != "" && \
$remote_ssh_domain != "" && \
$remote_ssh_port != "" && \
$remote_ssh_password != "" ]]; then
if [ ${#remote_ssh_password} -lt $MINIMUM_PASSWORD_LENGTH ]; then
dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters" 6 40
else
if [ ${#remote_ssh_password} -lt $MINIMUM_PASSWORD_LENGTH ]; then
dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters" 6 40
else
if [[ $RECIPROCAL == "yes" ]]; then
if [[ $remote_ssh_reciprocal_username != "" && \
$remote_ssh_reciprocal_password != "" ]]; then
if [ ${#remote_ssh_reciprocal_password} -lt $MINIMUM_PASSWORD_LENGTH ]; then
dialog --title "Password quality check" --msgbox "The reciprocal password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters" 6 40
else
echo ${remote_ssh_reciprocal_username}:${remote_ssh_reciprocal_password}::::/home/${remote_ssh_reciprocal_username}:bash | newusers
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
remote_ssh_reciprocal_username=""
remote_ssh_reciprocal_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
else
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
remote_ssh_reciprocal_username=""
remote_ssh_reciprocal_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
else
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
if [[ $RECIPROCAL == "yes" ]]; then
if [[ $remote_ssh_reciprocal_username != "" && \
$remote_ssh_reciprocal_password != "" ]]; then
if [ ${#remote_ssh_reciprocal_password} -lt $MINIMUM_PASSWORD_LENGTH ]; then
dialog --title "Password quality check" --msgbox "The reciprocal password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters" 6 40
else
echo ${remote_ssh_reciprocal_username}:${remote_ssh_reciprocal_password}::::/home/${remote_ssh_reciprocal_username}:bash | newusers
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
remote_ssh_reciprocal_username=""
remote_ssh_reciprocal_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
else
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
remote_ssh_reciprocal_username=""
remote_ssh_reciprocal_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
else
echo "$remote_ssh_username@$remote_ssh_domain $remote_ssh_port /home/$remote_ssh_username $remote_ssh_password" >> $FRIENDS_SERVERS_LIST
remote_ssh_username=""
remote_ssh_domain=""
remote_ssh_port=""
remote_ssh_password=""
entering_remote_backups_ctr=$((entering_remote_backups_ctr + 1))
fi
fi
else
entering_remote_backups_done="yes"
fi
fi
else
entering_remote_backups_done="yes"
fi
done
if [ -f $FRIENDS_SERVERS_LIST ]; then
chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
fi
}
function show_result {
clear
if (( $entering_remote_backups_ctr < 2 )); then
echo $'No remote backup locations were specified'
exit 0
echo $'No remote backup locations were specified'
exit 0
fi
if [ ! -f $FRIENDS_SERVERS_LIST ]; then
echo $"No remote backups list found: $FRIENDS_SERVERS_LIST"
exit 7358
echo $"No remote backups list found: $FRIENDS_SERVERS_LIST"
exit 7358
fi
echo ''
echo $"Remote backups list: $FRIENDS_SERVERS_LIST"
@ -254,7 +263,7 @@ function show_result {
}
if [ ! $FRIENDS_SERVERS_LIST ]; then
FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
fi
interactive_configuration_remote_backups