This commit is contained in:
Bob Mottram 2016-10-14 14:28:45 +01:00
parent 74bfce42dc
commit f95a702cac
1 changed files with 41 additions and 129 deletions

View File

@ -61,9 +61,6 @@ MUMBLE_ONION_PORT=8095
SSH_PORT=2222 SSH_PORT=2222
IRC_PORT=6697
IRC_ONION_PORT=8093
# outgoing SMTP proxy # outgoing SMTP proxy
SMTP_PROXY_ENABLE=$'no' SMTP_PROXY_ENABLE=$'no'
SMTP_PROXY_PROTOCOL='smtps' SMTP_PROXY_PROTOCOL='smtps'
@ -82,53 +79,22 @@ WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
USB_DRIVE=sdb USB_DRIVE=sdb
# get default USB from config file # get default USB from config file
CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "WIFI_HOTSPOT=" $CONFIGURATION_FILE; then
WIFI_HOTSPOT=$(cat $CONFIGURATION_FILE | grep "WIFI_HOTSPOT=" | awk -F '=' '{print $2}')
fi
if grep -q "WIFI_INTERFACE=" $CONFIGURATION_FILE; then
WIFI_INTERFACE=$(cat $CONFIGURATION_FILE | grep "WIFI_INTERFACE=" | awk -F '=' '{print $2}')
fi
if grep -q "WIFI_TYPE=" $CONFIGURATION_FILE; then
WIFI_TYPE=$(cat $CONFIGURATION_FILE | grep "WIFI_TYPE=" | awk -F '=' '{print $2}')
fi
if grep -q "WIFI_SSID=" $CONFIGURATION_FILE; then
WIFI_SSID=$(cat $CONFIGURATION_FILE | grep "WIFI_SSID=" | awk -F '=' '{print $2}')
fi
if grep -q "WIFI_PASSPHRASE=" $CONFIGURATION_FILE; then
WIFI_PASSPHRASE=$(cat $CONFIGURATION_FILE | grep "WIFI_PASSPHRASE=" | awk -F '=' '{print $2}')
fi
if grep -q "USB_DRIVE=" $CONFIGURATION_FILE; then
USB_DRIVE=$(cat $CONFIGURATION_FILE | grep "USB_DRIVE=" | awk -F '=' '{print $2}')
if [[ $USB_DRIVE == *"dev"* ]]; then
USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
fi
fi
if grep -q "SSH_PORT=" $CONFIGURATION_FILE; then
SSH_PORT=$(cat $CONFIGURATION_FILE | grep "SSH_PORT=" | awk -F '=' '{print $2}')
fi
if grep -q "IRC_PORT=" $CONFIGURATION_FILE; then
IRC_PORT=$(cat $CONFIGURATION_FILE | grep "IRC_PORT=" | awk -F '=' '{print $2}')
fi
if grep -q "SMTP_PROXY_ENABLE=" $CONFIGURATION_FILE; then read_config_param WIFI_HOTSPOT
SMTP_PROXY_ENABLE=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_ENABLE=" | awk -F '=' '{print $2}') read_config_param WIFI_INTERFACE
fi read_config_param WIFI_TYPE
if grep -q "SMTP_PROXY_PROTOCOL=" $CONFIGURATION_FILE; then read_config_param WIFI_SSID
SMTP_PROXY_PROTOCOL=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_PROTOCOL=" | awk -F '=' '{print $2}') read_config_param WIFI_PASSPHRASE
fi read_config_param SSH_PORT
if grep -q "SMTP_PROXY_SERVER=" $CONFIGURATION_FILE; then read_config_param SMTP_PROXY_ENABLE
SMTP_PROXY_SERVER=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_SERVER=" | awk -F '=' '{print $2}') read_config_param SMTP_PROXY_PROTOCOL
fi read_config_param SMTP_PROXY_SERVER
if grep -q "SMTP_PROXY_PORT=" $CONFIGURATION_FILE; then read_config_param SMTP_PROXY_PORT
SMTP_PROXY_PORT=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_PORT=" | awk -F '=' '{print $2}') read_config_param SMTP_PROXY_USERNAME
fi read_config_param SMTP_PROXY_PASSWORD
if grep -q "SMTP_PROXY_USERNAME=" $CONFIGURATION_FILE; then read_config_param USB_DRIVE
SMTP_PROXY_USERNAME=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_USERNAME=" | awk -F '=' '{print $2}') if [[ $USB_DRIVE == *"dev"* ]]; then
fi USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
if grep -q "SMTP_PROXY_PASSWORD=" $CONFIGURATION_FILE; then
SMTP_PROXY_PASSWORD=$(cat $CONFIGURATION_FILE | grep "SMTP_PROXY_PASSWORD=" | awk -F '=' '{print $2}')
fi
fi fi
# Mirrors settings # Mirrors settings
@ -190,23 +156,9 @@ function set_main_repo {
FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
if ! grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then write_config_param "FRIENDS_MIRRORS_SERVER" "$FRIENDS_MIRRORS_SERVER"
echo "FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER" >> $CONFIGURATION_FILE write_config_param "FRIENDS_MIRRORS_SSH_PORT" "$FRIENDS_MIRRORS_SSH_PORT"
else write_config_param "FRIENDS_MIRRORS_PASSWORD" "$FRIENDS_MIRRORS_PASSWORD"
sed -i "s|FRIENDS_MIRRORS_SERVER=.*|FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER|g" $CONFIGURATION_FILE
fi
if ! grep -q "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_MIRRORS_SSH_PORT=.*|FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT|g" $CONFIGURATION_FILE
fi
if ! grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_MIRRORS_PASSWORD=.*|FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD|g" $CONFIGURATION_FILE
fi
# re-read the repos # re-read the repos
read_repo_servers read_repo_servers
@ -270,7 +222,7 @@ function show_domains {
get_apps_installed_names get_apps_installed_names
clear clear
DEFAULT_DOMAIN_NAME=$(cat $CONFIGURATION_FILE | grep "DEFAULT_DOMAIN_NAME=" | awk -F '=' '{print $2}') read_config_param "DEFAULT_DOMAIN_NAME"
echo 'Domains' echo 'Domains'
echo '=======' echo '======='
@ -368,16 +320,18 @@ function show_users {
echo -n -e "$(pad_string ${USRNAME})" echo -n -e "$(pad_string ${USRNAME})"
# get the SIP extension # get the SIP extension
SIPEXT= SIPEXT=
while read ext; do if [ -f $SIP_CONFIGURATION_FILE ]; then
if [[ $ext == *"user id"* ]]; then while read ext; do
CURR_UID=$(echo "$ext" | awk -F '"' '{print $2}' | awk -F '"' '{print $1}') if [[ $ext == *"user id"* ]]; then
fi CURR_UID=$(echo "$ext" | awk -F '"' '{print $2}' | awk -F '"' '{print $1}')
if [[ $ext == *"extension"* ]]; then
if [[ $CURR_UID == $USRNAME ]]; then
SIPEXT=$(echo "$ext" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
fi fi
fi if [[ $ext == *"extension"* ]]; then
done < $SIP_CONFIGURATION_FILE if [[ $CURR_UID == $USRNAME ]]; then
SIPEXT=$(echo "$ext" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
fi
fi
done < $SIP_CONFIGURATION_FILE
fi
if [ $SIPEXT ]; then if [ $SIPEXT ]; then
echo -n -e "$(pad_string SIP:${SIPEXT})" echo -n -e "$(pad_string SIP:${SIPEXT})"
else else
@ -395,9 +349,7 @@ function show_mirrors_password {
if [ ! /home/mirrors ]; then if [ ! /home/mirrors ]; then
return return
fi fi
if grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then read_config_param "MY_MIRRORS_PASSWORD"
MY_MIRRORS_PASSWORD=$(grep "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
echo 'Local Mirrors' echo 'Local Mirrors'
echo '=============' echo '============='
echo '' echo ''
@ -501,36 +453,12 @@ function smtp_proxy {
fi fi
# save settings within the main configuration file # save settings within the main configuration file
if ! grep -q "SMTP_PROXY_ENABLE=" $CONFIGURATION_FILE; then write_config_param "SMTP_PROXY_ENABLE" "$SMTP_PROXY_ENABLE"
echo "SMTP_PROXY_ENABLE=$SMTP_PROXY_ENABLE" >> $CONFIGURATION_FILE write_config_param "SMTP_PROXY_PROTOCOL" "$SMTP_PROXY_PROTOCOL"
else write_config_param "SMTP_PROXY_SERVER" "$SMTP_PROXY_SERVER"
sed -i "s|SMTP_PROXY_ENABLE=.*|SMTP_PROXY_ENABLE=$SMTP_PROXY_ENABLE|g" $CONFIGURATION_FILE write_config_param "SMTP_PROXY_PORT" "$SMTP_PROXY_PORT"
fi write_config_param "SMTP_PROXY_USERNAME" "$SMTP_PROXY_USERNAME"
if ! grep -q "SMTP_PROXY_PROTOCOL=" $CONFIGURATION_FILE; then write_config_param "SMTP_PROXY_PASSWORD" "$SMTP_PROXY_PASSWORD"
echo "SMTP_PROXY_PROTOCOL=$SMTP_PROXY_PROTOCOL" >> $CONFIGURATION_FILE
else
sed -i "s|SMTP_PROXY_PROTOCOL=.*|SMTP_PROXY_PROTOCOL=$SMTP_PROXY_PROTOCOL|g" $CONFIGURATION_FILE
fi
if ! grep -q "SMTP_PROXY_SERVER=" $CONFIGURATION_FILE; then
echo "SMTP_PROXY_SERVER=$SMTP_PROXY_SERVER" >> $CONFIGURATION_FILE
else
sed -i "s|SMTP_PROXY_SERVER=.*|SMTP_PROXY_SERVER=$SMTP_PROXY_SERVER|g" $CONFIGURATION_FILE
fi
if ! grep -q "SMTP_PROXY_PORT=" $CONFIGURATION_FILE; then
echo "SMTP_PROXY_PORT=$SMTP_PROXY_PORT" >> $CONFIGURATION_FILE
else
sed -i "s|SMTP_PROXY_PORT=.*|SMTP_PROXY_PORT=$SMTP_PROXY_PORT|g" $CONFIGURATION_FILE
fi
if ! grep -q "SMTP_PROXY_USERNAME=" $CONFIGURATION_FILE; then
echo "SMTP_PROXY_USERNAME=$SMTP_PROXY_USERNAME" >> $CONFIGURATION_FILE
else
sed -i "s|SMTP_PROXY_USERNAME=.*|SMTP_PROXY_USERNAME=$SMTP_PROXY_USERNAME|g" $CONFIGURATION_FILE
fi
if ! grep -q "SMTP_PROXY_PASSWORD=" $CONFIGURATION_FILE; then
echo "SMTP_PROXY_PASSWORD=$SMTP_PROXY_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|SMTP_PROXY_PASSWORD=.*|SMTP_PROXY_PASSWORD=$SMTP_PROXY_PASSWORD|g" $CONFIGURATION_FILE
fi
} }
function delete_user { function delete_user {
@ -1535,26 +1463,10 @@ function hotspot_settings {
fi fi
# store any changes # store any changes
if ! grep -q "WIFI_HOTSPOT" $CONFIGURATION_FILE; then write_config_param "WIFI_HOTSPOT" "$WIFI_HOTSPOT"
echo "WIFI_HOTSPOT=$WIFI_HOTSPOT" >> $CONFIGURATION_FILE write_config_param "WIFI_SSID" "$WIFI_SSID"
else write_config_param "WIFI_TYPE" "$WIFI_TYPE"
sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=$WIFI_HOTSPOT|g" $CONFIGURATION_FILE write_config_param "WIFI_PASSPHRASE" "$WIFI_PASSPHRASE"
fi
if ! grep -q "WIFI_SSID" $CONFIGURATION_FILE; then
echo "WIFI_SSID=$WIFI_SSID" >> $CONFIGURATION_FILE
else
sed -i "s|WIFI_SSID=.*|WIFI_SSID=$WIFI_SSID|g" $CONFIGURATION_FILE
fi
if ! grep -q "WIFI_TYPE" $CONFIGURATION_FILE; then
echo "WIFI_TYPE=$WIFI_TYPE" >> $CONFIGURATION_FILE
else
sed -i "s|WIFI_TYPE=.*|WIFI_SSID=$WIFI_TYPE|g" $CONFIGURATION_FILE
fi
if ! grep -q "WIFI_PASSPHRASE" $CONFIGURATION_FILE; then
echo "WIFI_PASSPHRASE=$WIFI_PASSPHRASE" >> $CONFIGURATION_FILE
else
sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=$WIFI_PASSPHRASE|g" $CONFIGURATION_FILE
fi
dialog --title $"Wifi Settings" \ dialog --title $"Wifi Settings" \
--msgbox $"Hotspot settings were changed" 6 40 --msgbox $"Hotspot settings were changed" 6 40