freedombone/src/freedombone-controlpanel

1263 lines
44 KiB
Plaintext
Raw Normal View History

2015-10-31 21:14:23 +01:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Administrator control panel for the Freedombone system
#
# License
# =======
#
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-11-27 12:42:16 +01:00
PROJECT_NAME='freedombone'
2015-11-27 17:52:23 +01:00
export TEXTDOMAIN=${PROJECT_NAME}-controlpanel
2015-11-27 12:42:16 +01:00
export TEXTDOMAINDIR="/usr/share/locale"
2015-12-08 17:22:48 +01:00
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
2015-10-31 21:14:23 +01:00
SELECTED_USERNAME=
2015-11-02 17:28:18 +01:00
SIP_CONFIG_FILE=/etc/sipwitch.conf
2015-11-03 17:06:19 +01:00
ADMIN_USER=
2015-11-27 13:31:28 +01:00
UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
UPDATE_DATE_SCRIPT=/usr/bin/updatedate
2015-10-31 21:14:23 +01:00
2015-12-18 15:27:51 +01:00
USB_DRIVE=sdb
# get default USB from config file
CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
if [ -f $CONFIG_FILE ]; then
if grep -q "USB_DRIVE=" $CONFIG_FILE; then
USB_DRIVE=$(cat $CONFIG_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
fi
2015-10-31 21:14:23 +01:00
function any_key {
echo ' '
2015-12-03 15:52:31 +01:00
read -n1 -r -p $"Press any key to continue..." key
2015-10-31 21:14:23 +01:00
}
2015-11-26 11:53:54 +01:00
function check_for_updates {
if [ ! -f /etc/cron.weekly/$UPGRADE_SCRIPT_NAME ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Check for updates" \
--msgbox $"Upgrade script was not found" 6 40
2015-11-26 11:53:54 +01:00
return
fi
clear
2015-11-26 11:55:16 +01:00
. /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
2015-11-26 11:53:54 +01:00
any_key
}
2015-10-31 21:14:23 +01:00
function add_user {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Add new user" \
2015-10-31 21:14:23 +01:00
--form "\n" 8 40 3 \
2015-11-27 13:31:28 +01:00
$"Username:" 1 1 "" 1 11 16 15 \
$"ssh public key (optional):" 2 1 "" 3 1 40 10000 \
2015-10-31 21:14:23 +01:00
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
new_user_username=$(cat $data | sed -n 1p)
new_user_ssh_public_key=$(cat $data | sed -n 2p)
if [ ${#new_user_username} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"New username" \
--msgbox $"No username was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ "$new_user_username" == *" "* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Invalid username" \
--msgbox $"The username should not contain any spaces" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [ ${#new_user_ssh_public_key} -lt 20 ]; then
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-adduser "$new_user_username"
2015-10-31 21:14:23 +01:00
any_key
else
if [[ "$new_user_ssh_public_key" == "ssh-"* ]]; then
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-adduser "$new_user_username" "$new_user_ssh_public_key"
2015-10-31 21:14:23 +01:00
any_key
else
2015-11-27 13:31:28 +01:00
dialog --title $"ssh public key" \
--msgbox $"This does not look like an ssh public key" 6 40
2015-10-31 21:14:23 +01:00
fi
fi
}
2015-11-02 17:28:18 +01:00
function show_sip_extensions {
if [ ! -f $SIP_CONFIG_FILE ]; then
return;
fi
clear
2015-11-27 13:31:28 +01:00
echo $"SIP phone extensions:"
2015-11-02 17:28:18 +01:00
echo " "
while read ext; do
if [[ $ext == *"user id"* ]]; then
echo -n " "
echo -n $(echo "$ext" | awk -F '"' '{print $2}' | awk -F '"' '{print $1}')
echo -n " "
fi
if [[ $ext == *"extension"* ]]; then
echo $(echo "$ext" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
fi
done < $SIP_CONFIG_FILE
any_key
2015-11-02 17:28:18 +01:00
}
2015-10-31 21:14:23 +01:00
function select_user {
SELECTED_USERNAME=
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title "Select a user" \
2015-11-27 13:31:28 +01:00
--backtitle $"Freedombone Control Panel" \
2015-10-31 21:14:23 +01:00
--dselect "/home/" 14 40 2> $data
sel=$?
case $sel in
0) SELECTED_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
2015-11-01 11:56:33 +01:00
1) return;;
255) return;;
2015-10-31 21:14:23 +01:00
esac
if [ ${#SELECTED_USERNAME} -lt 2 ]; then
SELECTED_USERNAME=
fi
2015-12-23 14:21:02 +01:00
if [ ! -d /home/$SELECTED_USERNAME ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"User directory check" \
--msgbox $"This does not look like a user directory" 6 40
2015-10-31 21:14:23 +01:00
SELECTED_USERNAME=
fi
}
function delete_user {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
2015-11-27 13:31:28 +01:00
dialog --title $"Administrator user" \
--msgbox $"You can't delete the administrator user" 6 40
2015-10-31 21:14:23 +01:00
return
fi
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-rmuser $SELECTED_USERNAME
2015-10-31 21:14:23 +01:00
any_key
}
function configure_remote_backups {
2015-12-22 21:30:28 +01:00
if ! grep -Fxq "Admin user:$ADMIN_USER" $COMPLETION_FILE; then
2015-11-27 13:31:28 +01:00
dialog --title $"Administrator user" \
--msgbox $"No Administrator user found. Check $COMPLETION_FILE" 6 40
return
fi
2015-12-22 21:33:06 +01:00
if [ ${#ADMIN_USER} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Administrator user" \
--msgbox $"Username not found" 6 40
return
fi
if [ ! -d /home/$ADMIN_USER ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Administrator user" \
--msgbox $"Home directory not found" 6 40
return
fi
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-remote -u $ADMIN_USER
2015-12-22 21:55:20 +01:00
if [ ! "$?" = "0" ]; then
any_key
fi
}
2015-10-31 21:14:23 +01:00
function change_password {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
clear
2015-11-27 13:31:28 +01:00
echo -n $"Change password for"
echo " $SELECTED_USERNAME"
2015-11-01 10:51:10 +01:00
echo ""
2015-10-31 21:14:23 +01:00
su -c "passwd" - $SELECTED_USERNAME
any_key
}
function irc_set_global_password {
dialog --title $"IRC Password" \
--clear \
--backtitle $"Freedombone Control Panel" \
2015-12-10 18:23:48 +01:00
--passwordbox $"Password for all IRC users, or press Enter for no password" 10 50 2> $data
sel=$?
case $sel in
0)
NEW_IRC_PASSWORD=$(<$data)
2015-12-20 20:28:28 +01:00
sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf
dialog --title $"IRC Password" \
--msgbox $"The IRC password was changed" 6 40
;;
esac
}
2015-11-01 11:51:54 +01:00
function change_ssh_public_key {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
2015-11-27 13:31:28 +01:00
dialog --title $"Change ssh public key" \
--backtitle $"Freedombone Control Panel" \
2015-11-01 11:51:54 +01:00
--defaultno \
2015-11-27 13:31:28 +01:00
--yesno $"\nThis is the administrator user.\n\nAre you sure you want to change the ssh public key for the administrator?" 10 60
2015-11-01 11:51:54 +01:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --title $"Change ssh public key for $SELECTED_USERNAME" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"Paste the ssh public key below" 8 60 2>$data
2015-11-01 11:51:54 +01:00
sel=$?
case $sel in
0)
SSH_PUBLIC_KEY=$(<$data)
if [ "$SSH_PUBLIC_KEY" ]; then
if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
if [ -f "$SSH_PUBLIC_KEY" ]; then
if [ ! -d /home/$SELECTED_USERNAME/.ssh ]; then
mkdir /home/$SELECTED_USERNAME/.ssh
fi
cp $SSH_PUBLIC_KEY \
/home/$SELECTED_USERNAME/.ssh/authorized_keys
chown -R $SELECTED_USERNAME:$SELECTED_USERNAME \
/home/$SELECTED_USERNAME/.ssh
2015-11-27 13:31:28 +01:00
dialog --title $"Change ssh public key" \
--msgbox $"ssh public key was installed" 6 40
2015-11-01 11:51:54 +01:00
else
if [[ "$SSH_PUBLIC_KEY" == "ssh-"* ]]; then
if [ ! -d /home/$SELECTED_USERNAME/.ssh ]; then
mkdir /home/$SELECTED_USERNAME/.ssh
fi
echo "$SSH_PUBLIC_KEY" > \
/home/$SELECTED_USERNAME/.ssh/authorized_keys
chown -R $SELECTED_USERNAME:$SELECTED_USERNAME \
/home/$SELECTED_USERNAME/.ssh
2015-11-27 13:31:28 +01:00
dialog --title $"Change ssh public key" \
--msgbox $"ssh public key was installed" 6 40
2015-11-01 11:51:54 +01:00
fi
fi
fi
fi
;;
esac
}
2015-10-31 21:14:23 +01:00
function add_to_mailing_list {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Subscribe $SELECTED_USERNAME to a mailing list" \
2015-10-31 21:14:23 +01:00
--form "\n" 8 68 4 \
2015-11-27 13:31:28 +01:00
$"List folder name:" 1 1 "" 1 35 26 25 \
$"Name between [] on subject line:" 2 1 "" 2 35 26 25 \
$"List email address:" 3 1 "" 3 35 26 25 \
2015-10-31 21:14:23 +01:00
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
LIST_NAME=$(cat $data | sed -n 1p)
LIST_SUBJECT=$(cat $data | sed -n 2p)
LIST_EMAIL=$(cat $data | sed -n 3p)
if [ ${#LIST_NAME} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add mailing list" \
--msgbox $"No mailing list name was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [ ${#LIST_SUBJECT} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add mailing list" \
--msgbox $"No mailing list subject was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [ ${#LIST_EMAIL} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add mailing list" \
--msgbox $"No mailing list email address was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ "$LIST_EMAIL" != *"@"* || "$LIST_EMAIL" != *"."* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add mailing list" \
--msgbox $"Unrecognised email address" 6 40
2015-10-31 21:14:23 +01:00
return
fi
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" \
2015-11-01 11:08:36 +01:00
-s "$LIST_SUBJECT" -e "$LIST_EMAIL"
2015-11-27 13:31:28 +01:00
dialog --title $"Add mailing list" \
--msgbox $"$LIST_NAME list was added" 6 40
2015-10-31 21:14:23 +01:00
}
function email_rule {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Email rule for user $SELECTED_USERNAME" \
2015-10-31 21:14:23 +01:00
--form "\n" 8 65 3 \
2015-11-27 13:31:28 +01:00
$"When email arrives from address:" 1 1 "" 1 35 24 28 \
$"Move to folder:" 2 1 "" 2 35 24 28 \
2015-10-31 21:14:23 +01:00
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
RULE_EMAIL=$(cat $data | sed -n 1p)
RULE_FOLDER=$(cat $data | sed -n 2p)
if [ ${#RULE_EMAIL} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add email rule" \
--msgbox $"No email address was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [ ${#RULE_FOLDER} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add email rule" \
--msgbox $"No folder name was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ "$RULE_EMAIL" != *"@"* || "$RULE_EMAIL" != *"."* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Add email rule" \
--msgbox $"Unrecognised email address" 6 40
2015-10-31 21:14:23 +01:00
return
fi
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-addemail -u $SELECTED_USERNAME -e "$RULE_EMAIL" \
2015-11-01 11:08:36 +01:00
-g "$RULE_FOLDER"
2015-11-27 13:31:28 +01:00
dialog --title $"Add email rule" \
--msgbox $"Email rule for $RULE_EMAIL was added" 6 40
2015-10-31 21:14:23 +01:00
}
function block_unblock_email {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
2015-12-02 18:30:44 +01:00
blockstr=$"Block/Unblock email going to"
2015-10-31 21:14:23 +01:00
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title "$blockstr $SELECTED_USERNAME" \
2015-10-31 21:14:23 +01:00
--form "\n" 8 65 3 \
2015-11-27 13:31:28 +01:00
$"When email arrives from address:" 1 1 "" 1 35 24 28 \
$"Block it:" 2 1 "yes" 2 35 4 4 \
2015-10-31 21:14:23 +01:00
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
BLOCK_EMAIL=$(cat $data | sed -n 1p)
BLOCK=$(cat $data | sed -n 2p)
if [ ${#BLOCK_EMAIL} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Block/Unblock an email" \
--msgbox $"No email address was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ "$BLOCK_EMAIL" != *"@"* || "$BLOCK_EMAIL" != *"."* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Block/Unblock an email" \
--msgbox $"Unrecognised email address" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-ignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
2015-11-27 13:31:28 +01:00
dialog --title $"Block an email" \
2015-11-01 11:08:36 +01:00
--msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME blocked" 6 40
2015-10-31 21:14:23 +01:00
else
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-unignore -u $SELECTED_USERNAME -e "$BLOCK_EMAIL"
2015-11-27 13:31:28 +01:00
dialog --title $"Unblock an email" \
2015-11-01 11:08:36 +01:00
--msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME unblocked" 6 40
2015-10-31 21:14:23 +01:00
fi
}
function block_unblock_subject {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
2015-12-02 18:30:44 +01:00
blockstr=$"Block/Unblock email going to"
2015-10-31 21:14:23 +01:00
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title "$blockstr $SELECTED_USERNAME" \
2015-10-31 21:14:23 +01:00
--form "\n" 8 70 3 \
2015-11-27 13:31:28 +01:00
$"When email arrives with subject text:" 1 1 "" 1 40 24 28 \
$"Block it:" 2 1 "yes" 2 40 4 4 \
2015-10-31 21:14:23 +01:00
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
BLOCK_SUBJECT=$(cat $data | sed -n 1p)
BLOCK=$(cat $data | sed -n 2p)
if [ ${#BLOCK_SUBJECT} -lt 2 ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Block/Unblock an email" \
--msgbox $"No subject was given" 6 40
2015-10-31 21:14:23 +01:00
return
fi
if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-ignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
2015-11-27 13:31:28 +01:00
dialog --title $"Block an email" \
2015-11-01 11:08:36 +01:00
--msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME blocked" 6 40
2015-10-31 21:14:23 +01:00
else
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-unignore -u $SELECTED_USERNAME -t "$BLOCK_SUBJECT"
2015-11-27 13:31:28 +01:00
dialog --title $"Unblock an email" \
2015-11-01 11:08:36 +01:00
--msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME unblocked" 6 40
2015-10-31 21:14:23 +01:00
fi
}
function create_keydrive_master {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
2015-11-27 13:31:28 +01:00
dialog --title $"USB Master Keydrive" \
--msgbox $"Plug in a LUKS encrypted USB drive" 6 40
2015-10-31 21:14:23 +01:00
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-keydrive -u $SELECTED_USERNAME --master 'yes'
2015-10-31 21:14:23 +01:00
any_key
}
function create_keydrive_fragment {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
2015-11-27 13:31:28 +01:00
dialog --title $"USB Fragment Keydrive" \
--msgbox $"Plug in a LUKS encrypted USB drive" 6 40
2015-10-31 21:14:23 +01:00
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-keydrive -u $SELECTED_USERNAME
2015-10-31 21:14:23 +01:00
any_key
}
function backup_data {
2015-11-27 13:31:28 +01:00
dialog --title $"Backup data to USB" \
--msgbox $"Plug in a LUKS encrypted USB drive" 6 40
2015-10-31 21:14:23 +01:00
clear
2015-11-05 10:06:19 +01:00
echo ' '
2015-11-27 13:31:28 +01:00
echo $'Enter the passphrase for your LUKS encrypted backup drive:'
2015-12-09 18:12:16 +01:00
${PROJECT_NAME}-backup-local
2015-10-31 21:14:23 +01:00
any_key
}
2015-12-18 15:27:51 +01:00
function restore_from_usb {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Restore from USB backup" \
--radiolist $"Choose an application to restore:" 30 70 27 \
1 $"Everything" on \
2 $"Return to the backup and restore menu" off \
3 $"Configuration files" off \
4 $"MariaDB settings" off \
5 $"Let's Encrypt account" off \
6 $"Mutt email client settings" off \
7 $"GPG keys" off \
8 $"Email processing rules" off \
9 $"Spam filtering rules" off \
10 $"Administrator's README file" off \
11 $"IPFS" off \
12 $"SSH keys" off \
13 $"User configuration files" off \
14 $"SSL/TLS certificates" off \
15 $"Personal settings" off \
16 $"Mailing List" off \
17 $"XMPP chat" off \
18 $"GNU Social" off \
19 $"Hubzilla" off \
20 $"Owncloud" off \
21 $"Gogs" off \
22 $"Wiki" off \
23 $"Blog" off \
24 $"CJDNS" off \
25 $"Email" off \
26 $"DLNA" off \
27 $"VoIP" off \
28 $"Tox" off 2> $data
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
2015-12-18 15:34:37 +01:00
1) ${PROJECT_NAME}-restore-local $USB_DRIVE;;
2015-12-18 15:27:51 +01:00
2) return;;
2015-12-18 15:34:37 +01:00
3) ${PROJECT_NAME}-restore-local $USB_DRIVE configuration;;
4) ${PROJECT_NAME}-restore-local $USB_DRIVE mariadb;;
5) ${PROJECT_NAME}-restore-local $USB_DRIVE letsencrypt;;
6) ${PROJECT_NAME}-restore-local $USB_DRIVE mutt;;
7) ${PROJECT_NAME}-restore-local $USB_DRIVE gpg;;
8) ${PROJECT_NAME}-restore-local $USB_DRIVE procmail;;
9) ${PROJECT_NAME}-restore-local $USB_DRIVE spamassassin;;
10) ${PROJECT_NAME}-restore-local $USB_DRIVE readme;;
11) ${PROJECT_NAME}-restore-local $USB_DRIVE ipfs;;
12) ${PROJECT_NAME}-restore-local $USB_DRIVE ssh;;
13) ${PROJECT_NAME}-restore-local $USB_DRIVE userconfig;;
14) ${PROJECT_NAME}-restore-local $USB_DRIVE certs;;
15) ${PROJECT_NAME}-restore-local $USB_DRIVE personal;;
16) ${PROJECT_NAME}-restore-local $USB_DRIVE mailinglist;;
17) ${PROJECT_NAME}-restore-local $USB_DRIVE xmpp;;
18) ${PROJECT_NAME}-restore-local $USB_DRIVE gnusocial;;
19) ${PROJECT_NAME}-restore-local $USB_DRIVE hubzilla;;
20) ${PROJECT_NAME}-restore-local $USB_DRIVE owncloud;;
21) ${PROJECT_NAME}-restore-local $USB_DRIVE gogs;;
22) ${PROJECT_NAME}-restore-local $USB_DRIVE wiki;;
23) ${PROJECT_NAME}-restore-local $USB_DRIVE blog;;
24) ${PROJECT_NAME}-restore-local $USB_DRIVE cjdns;;
25) ${PROJECT_NAME}-restore-local $USB_DRIVE email;;
26) ${PROJECT_NAME}-restore-local $USB_DRIVE dlna;;
27) ${PROJECT_NAME}-restore-local $USB_DRIVE voip;;
28) ${PROJECT_NAME}-restore-local $USB_DRIVE tox;;
2015-12-18 15:27:51 +01:00
esac
done
any_key
}
function restore_from_remote {
remote_domain_name=$1
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Restore from ${remote_domain_name}" \
--radiolist $"Choose an application to restore:" 30 70 27 \
1 $"Everything" on \
2 $"Return to the backup and restore menu" off \
3 $"Configuration files" off \
4 $"MariaDB settings" off \
5 $"Let's Encrypt account" off \
6 $"Mutt email client settings" off \
7 $"GPG keys" off \
8 $"Email processing rules" off \
9 $"Spam filtering rules" off \
10 $"Administrator's README file" off \
11 $"IPFS" off \
12 $"SSH keys" off \
13 $"User configuration files" off \
14 $"SSL/TLS certificates" off \
15 $"Personal settings" off \
16 $"Mailing List" off \
17 $"XMPP chat" off \
18 $"GNU Social" off \
19 $"Hubzilla" off \
20 $"Owncloud" off \
21 $"Gogs" off \
22 $"Wiki" off \
23 $"Blog" off \
24 $"CJDNS" off \
25 $"Email" off \
26 $"DLNA" off \
27 $"VoIP" off \
28 $"Tox" off 2> $data
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
1) ${PROJECT_NAME}-restore-remote $remote_domain_name;;
2) return;;
3) ${PROJECT_NAME}-restore-remote $remote_domain_name configuration;;
4) ${PROJECT_NAME}-restore-remote $remote_domain_name mariadb;;
5) ${PROJECT_NAME}-restore-remote $remote_domain_name letsencrypt;;
6) ${PROJECT_NAME}-restore-remote $remote_domain_name mutt;;
7) ${PROJECT_NAME}-restore-remote $remote_domain_name gpg;;
8) ${PROJECT_NAME}-restore-remote $remote_domain_name procmail;;
9) ${PROJECT_NAME}-restore-remote $remote_domain_name spamassassin;;
10) ${PROJECT_NAME}-restore-remote $remote_domain_name readme;;
11) ${PROJECT_NAME}-restore-remote $remote_domain_name ipfs;;
12) ${PROJECT_NAME}-restore-remote $remote_domain_name ssh;;
13) ${PROJECT_NAME}-restore-remote $remote_domain_name userconfig;;
14) ${PROJECT_NAME}-restore-remote $remote_domain_name certs;;
15) ${PROJECT_NAME}-restore-remote $remote_domain_name personal;;
16) ${PROJECT_NAME}-restore-remote $remote_domain_name mailinglist;;
17) ${PROJECT_NAME}-restore-remote $remote_domain_name xmpp;;
18) ${PROJECT_NAME}-restore-remote $remote_domain_name gnusocial;;
19) ${PROJECT_NAME}-restore-remote $remote_domain_name hubzilla;;
20) ${PROJECT_NAME}-restore-remote $remote_domain_name owncloud;;
21) ${PROJECT_NAME}-restore-remote $remote_domain_name gogs;;
22) ${PROJECT_NAME}-restore-remote $remote_domain_name wiki;;
23) ${PROJECT_NAME}-restore-remote $remote_domain_name blog;;
24) ${PROJECT_NAME}-restore-remote $remote_domain_name cjdns;;
25) ${PROJECT_NAME}-restore-remote $remote_domain_name email;;
26) ${PROJECT_NAME}-restore-remote $remote_domain_name dlna;;
27) ${PROJECT_NAME}-restore-remote $remote_domain_name voip;;
28) ${PROJECT_NAME}-restore-remote $remote_domain_name tox;;
esac
done
any_key
}
2015-10-31 21:14:23 +01:00
function restore_data {
2015-11-27 13:31:28 +01:00
dialog --title $"Restore data from USB" \
--msgbox $"Plug in your backup USB drive" 6 40
2015-10-31 21:14:23 +01:00
clear
2015-11-05 10:06:19 +01:00
echo ' '
2015-11-27 13:31:28 +01:00
echo $'Enter the passphrase for your LUKS encrypted backup drive:'
2015-12-18 15:27:51 +01:00
restore_from_usb
2015-10-31 21:14:23 +01:00
}
2015-10-31 22:01:24 +01:00
function restore_data_remote {
2015-11-03 17:06:19 +01:00
if [ ! $ADMIN_USER ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Restore data from remote server" \
--msgbox $"Unknown admin user" 6 40
2015-11-03 17:06:19 +01:00
return
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --title $"Restore from remote server" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"Enter the domain name of the server from which you wish to restore" 8 60 2>$data
2015-11-03 17:06:19 +01:00
sel=$?
case $sel in
0)
friend_server_domain_name=$(<$data)
if [ ${#friend_server_domain_name} -lt 2 ]; then
return
fi
if [[ $friend_server_domain_name != *"."* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Remote server domain name" \
--msgbox $"Invalid domain name" 6 40
2015-11-03 17:06:19 +01:00
return
fi
restore_from_remote $friend_server_domain_name
2015-11-03 17:06:19 +01:00
;;
esac
2015-10-31 22:01:24 +01:00
}
2015-10-31 23:55:09 +01:00
function logging_on_off {
logging="no"
2015-11-27 13:31:28 +01:00
dialog --title $"Logging" \
--backtitle $"Freedombone Control Panel" \
--yesno $"\nDo you want to turn logging on?" 7 60
2015-11-01 00:09:32 +01:00
sel=$?
case $sel in
0) logging="yes";;
2015-11-01 00:09:32 +01:00
255) return;;
esac
clear
echo ''
2015-11-27 13:31:28 +01:00
echo $'This may take a few seconds. Please wait...'
if [[ $logging == "no" ]]; then
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-logging off
else
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-logging on
fi
2015-10-31 23:55:09 +01:00
}
2015-10-31 22:01:24 +01:00
function restore_gpg_key {
select_user
if [ ! $SELECTED_USERNAME ]; then
return
fi
2015-12-02 18:30:44 +01:00
restorestr=$"Restore GPG key for user"
2015-11-27 13:31:28 +01:00
dialog --title "$restorestr $SELECTED_USERNAME" \
--msgbox $"Plug in your USB keydrive" 6 40
2015-10-31 22:01:24 +01:00
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-recoverkey -u $SELECTED_USERNAME
2015-10-31 22:01:24 +01:00
any_key
}
2015-11-03 10:24:55 +01:00
function security_settings {
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-sec
2015-11-03 10:24:55 +01:00
any_key
}
function reset_tripwire {
clear
2015-11-27 13:31:28 +01:00
echo $'Resetting the Tripwire...'
2015-11-03 10:37:16 +01:00
echo ' '
echo '
' | reset-tripwire
any_key
}
2015-11-17 23:21:40 +01:00
function hubzilla_renew_cert {
2015-11-27 13:31:28 +01:00
dialog --title $"Renew SSL certificate" \
--backtitle $"Freedombone Control Panel" \
--yesno $"\nThis will renew a letsencrypt certificate. Select 'yes' to continue" 16 60
2015-11-17 23:21:40 +01:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Renew SSL certificate" \
--msgbox $"Hubzilla install directory not found" 6 40
2015-11-17 23:21:40 +01:00
return
fi
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-renew-cert -h $HUBZILLA_DOMAIN_NAME -p 'letsencrypt'
2015-11-17 23:21:40 +01:00
if [ ! "$?" = "0" ]; then
any_key
else
2015-11-27 13:31:28 +01:00
dialog --title $"Renew SSL certificate" \
--msgbox $"Hubzilla certificate has been renewed" 6 40
2015-11-17 23:21:40 +01:00
fi
}
function hubzilla_channel_directory_server {
if ! grep -q "Hubzilla domain" $COMPLETION_FILE; then
2015-11-27 13:31:28 +01:00
dialog --title $"Hubzilla channel directory server" \
--msgbox $"Hubzilla is not installed on this system" 6 40
return
fi
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
2015-11-17 23:21:40 +01:00
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Hubzilla channel directory server" \
--msgbox $"Hubzilla install directory not found" 6 40
return
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --title $"Hubzilla channel directory server" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"When you click on 'channel directory' this is where Hubzilla will obtain its list from" 8 60 2>$data
sel=$?
case $sel in
0)
hubzilla_domain_server=$(<$data)
2015-11-03 13:30:28 +01:00
if [[ $hubzilla_domain_server != *"."* ]]; then
return
fi
if [[ $hubzilla_domain_server != "https"* ]]; then
2015-11-27 13:31:28 +01:00
dialog --title $"Hubzilla channel directory server" \
--msgbox $"Invalid domain - include the https://" 6 40
2015-11-03 13:30:28 +01:00
return
fi
./var/www/$HUBZILLA_DOMAIN_NAME/htdocs/util/config system directory_server $hubzilla_domain_server
2015-11-27 13:31:28 +01:00
dialog --title $"Hubzilla channel directory server" \
--msgbox $"Domain channel directory server changed to $hubzilla_domain_server" 6 40
;;
esac
}
function format_drive {
drive=
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Format a USB drive (LUKS encrypted)" \
--radiolist $"Choose a drive:" 12 70 5 \
1 $"sda (Beaglebone Black)" off \
2 $"sdb" off \
3 $"sdc" off \
4 $"sdd" off \
5 $"Back to Backup and Restore menu" on 2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) drive='sda';;
2) drive='sdb';;
3) drive='sdc';;
4) drive='sdd';;
5) return;;
esac
2015-11-27 13:31:28 +01:00
dialog --title $"Format USB drive" \
--backtitle $"Freedombone Control Panel" \
--defaultno \
2015-11-27 13:31:28 +01:00
--yesno $"\nPlease confirm that you wish to format drive\n\n ${drive}\n\nAll current data on the drive will be lost, and you will be prompted to give a password used to encrypt the drive.\n\nDANGER: If you screw up here and format the wrong drive it's your own fault!" 16 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
clear
2015-12-08 17:22:48 +01:00
${PROJECT_NAME}-format $drive
any_key
}
2015-12-09 10:58:58 +01:00
function remove_backups {
drive=
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Remove backups from a USB drive" \
--radiolist $"Choose a drive:" 12 70 5 \
1 $"sda (Beaglebone Black)" off \
2 $"sdb" off \
3 $"sdc" off \
4 $"sdd" off \
5 $"Back to Backup and Restore menu" on 2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) drive='sda';;
2) drive='sdb';;
3) drive='sdc';;
4) drive='sdd';;
5) return;;
esac
dialog --title $"Remove backups from a USB drive" \
--backtitle $"Freedombone Control Panel" \
--defaultno \
--yesno $"\nPlease confirm that you wish to remove backups from this drive\n\n ${drive}\n\nYou will not be able to recover them afterwards." 12 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
clear
${PROJECT_NAME}-backup-local $drive remove
any_key
}
2015-11-21 21:01:53 +01:00
function shut_down_system {
2015-11-27 13:31:28 +01:00
dialog --title $"Power off the system" \
--backtitle $"Freedombone Control Panel" \
2015-11-21 21:01:53 +01:00
--defaultno \
2015-11-27 13:31:28 +01:00
--yesno $"\nPlease confirm that you wish to power off the system.\n\nWARNING: to power on again you will need to have physical access to the hardware." 10 60
2015-11-21 21:01:53 +01:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
shutdown now
}
function restart_system {
2015-11-27 13:31:28 +01:00
dialog --title $"Restart the system" \
--backtitle $"Freedombone Control Panel" \
2015-11-21 21:01:53 +01:00
--defaultno \
2015-11-27 13:31:28 +01:00
--yesno $"\nPlease confirm that you wish to restart the system.\n\nWARNING: If you are using full disk encryption then you will need physical access to the hardware to type in the password" 10 60
2015-11-21 21:01:53 +01:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
reboot
}
2015-12-02 18:30:44 +01:00
function change_system_name {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Change the name of this system" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Enter a new name for this system on your local network\n\nIt will appear as newname.local' 10 60 2>$data
sel=$?
case $sel in
0) NEW_SYSTEM_NAME=$(<$data)
if [ "$NEW_SYSTEM_NAME" ]; then
if [ ${#NEW_SYSTEM_NAME} -gt 1 ]; then
sed -i "s|host-name=.*|host-name=$NEW_SYSTEM_NAME|g" /etc/avahi/avahi-daemon.conf
systemctl restart avahi-daemon
if grep -q "host-name=$NEW_SYSTEM_NAME" /etc/avahi/avahi-daemon.conf; then
dialog --title $"New local network name" \
--msgbox $"The name of this system on your local network was changed successfully" 6 70
fi
fi
fi
;;
esac
}
function set_tls_time_source {
2015-12-07 11:58:30 +01:00
TLS_DATE_SOURCE=$(cat /usr/bin/updatedate | grep "TIMESOURCE='" | awk -F '=' '{print $2}' | awk -F "'" '{print $2}')
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Set the TLS date/time source" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"Enter a domain name to use as a TLS time source.\n\nFactors to consider when choosing a source are whether you wish that site to know that your system is 'alive' and also what might happen if an adversary were to try to mess with the date/time from that domain (i.e. how much blowback would there be)." 14 60 "$TLS_DATE_SOURCE" 2>$data
sel=$?
case $sel in
0) NEW_TLS_DATE_SOURCE=$(<$data)
if [[ $NEW_TLS_DATE_SOURCE == *"."* && $NEW_TLS_DATE_SOURCE != *'/'* ]]; then
if [[ $NEW_TLS_DATE_SOURCE != "http"* ]]; then
2015-12-07 11:58:30 +01:00
sed -i "s|TIMESOURCE='.*|TIMESOURCE='${NEW_TLS_DATE_SOURCE}'|g" $UPDATE_DATE_SCRIPT
else
dialog --title $"Invalid domain name" \
--msgbox $"Don't include the 'https'" 6 70
fi
else
dialog --title $"Invalid domain name" \
--msgbox $"That doesn't look like a domain name" 6 70
fi
;;
esac
}
2015-12-07 15:30:19 +01:00
function set_static_IP {
STATIC_IP='192.168.1.60'
STATIC_GATEWAY='192.168.1.1'
NEW_STATIC_IP=
NEW_STATIC_GATEWAY=
if grep -q 'iface eth0 inet static' /etc/network/interfaces; then
STATIC_IP=$(cat /etc/network/interfaces | grep "address " | awk -F ' ' '{print $2}' | head -n 1)
STATIC_GATEWAY=$(cat /etc/network/interfaces | grep "gateway " | awk -F ' ' '{print $2}' | head -n 1)
fi
# get the IP for the box
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Set a static local IP address" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"In order to forward incoming internet traffic to this system most internet routers need to know a static local IP address to send the data to.\n\n
Enter a static local IP address for this system.\n\nIt will typically be 192.168.1.x" 15 60 "$STATIC_IP" 2>$data
sel=$?
case $sel in
0) NEW_STATIC_IP=$(<$data)
if [[ "$NEW_STATIC_IP" != *"."* ]]; then
return
fi
if grep -q 'iface eth0 inet static' /etc/network/interfaces; then
if [[ "$NEW_STATIC_IP" != "$STATIC_IP" ]]; then
sed -i "s|${STATIC_IP}|${NEW_STATIC_IP}|g" /etc/network/interfaces
fi
fi
;;
esac
# get the gateway
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Set the IP address of your internet router/modem" \
--backtitle $"Freedombone Control Panel" \
--inputbox $"Set the local IP address for your internet router or ADSL modem.\n\nIt will typically be 192.168.1.1, 192.168.1.254, or similar" 12 60 "$STATIC_GATEWAY" 2>$data
sel=$?
case $sel in
0) NEW_STATIC_GATEWAY=$(<$data)
if [[ "$NEW_STATIC_GATEWAY" != *"."* ]]; then
return
fi
if grep -q 'iface eth0 inet static' /etc/network/interfaces; then
if [[ "$NEW_STATIC_GATEWAY" != "$STATIC_GATEWAY" ]]; then
sed -i "s|${STATIC_GATEWAY}|${NEW_STATIC_GATEWAY}|g" /etc/network/interfaces
fi
return
fi
;;
esac
if ! grep -q 'iface eth0 inet static' /etc/network/interfaces; then
if [ "$NEW_STATIC_GATEWAY" && "$NEW_STATIC_IP" ]; then
echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
echo '' >> /etc/network/interfaces
echo '# The loopback network interface' >> /etc/network/interfaces
echo 'auto lo' >> /etc/network/interfaces
echo 'iface lo inet loopback' >> /etc/network/interfaces
echo '' >> /etc/network/interfaces
echo '# The primary network interface' >> /etc/network/interfaces
echo 'auto eth0' >> /etc/network/interfaces
echo 'iface eth0 inet static' >> /etc/network/interfaces
echo " address ${NEW_STATIC_IP}" >> /etc/network/interfaces
echo ' netmask 255.255.255.0' >> /etc/network/interfaces
echo " gateway ${NEW_STATIC_GATEWAY}" >> /etc/network/interfaces
echo " dns-nameservers 213.73.91.35 85.214.20.141" >> /etc/network/interfaces
echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
echo '' >> /etc/network/interfaces
echo '# The secondary network interface' >> /etc/network/interfaces
echo '#auto eth1' >> /etc/network/interfaces
echo '#iface eth1 inet dhcp' >> /etc/network/interfaces
echo '' >> /etc/network/interfaces
echo '# WiFi Example' >> /etc/network/interfaces
echo "#auto $WIFI_INTERFACE" >> /etc/network/interfaces
echo "#iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces
echo '# wpa-ssid "essid"' >> /etc/network/interfaces
echo '# wpa-psk "password"' >> /etc/network/interfaces
echo '' >> /etc/network/interfaces
echo '# Ethernet/RNDIS gadget (g_ether)' >> /etc/network/interfaces
echo '# ... or on host side, usbnet and random hwaddr' >> /etc/network/interfaces
echo '# Note on some boards, usb0 is automaticly setup with an init script' >> /etc/network/interfaces
echo '#iface usb0 inet static' >> /etc/network/interfaces
echo '# address 192.168.7.2' >> /etc/network/interfaces
echo '# netmask 255.255.255.0' >> /etc/network/interfaces
echo '# network 192.168.7.0' >> /etc/network/interfaces
echo '# gateway 192.168.7.1' >> /etc/network/interfaces
fi
fi
}
2015-11-01 11:29:42 +01:00
function menu_backup_restore {
2015-10-31 21:14:23 +01:00
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Backup and Restore" \
2015-12-09 10:58:58 +01:00
--radiolist $"Choose an operation:" 18 70 11 \
2015-11-27 13:31:28 +01:00
1 $"Backup data to USB drive" off \
2 $"Restore GPG key from USB keydrive" off \
3 $"Restore data from USB drive" off \
2015-12-18 15:40:46 +01:00
4 $"Configure remote backups" off \
5 $"Restore from remote backup" off \
6 $"Backup GPG key to USB (master keydrive)" off \
7 $"Backup GPG key to USB (fragment keydrive)" off \
8 $"Format a USB drive (LUKS encrypted)" off \
9 $"Remove backups from a USB drive" off \
10 $"Back to main menu" on 2> $data
2015-10-31 21:14:23 +01:00
sel=$?
case $sel in
2015-11-01 11:56:33 +01:00
1) break;;
255) break;;
2015-10-31 21:14:23 +01:00
esac
case $(cat $data) in
1) backup_data;;
2015-11-01 11:29:42 +01:00
2) restore_gpg_key;;
3) restore_data;;
2015-12-18 15:40:46 +01:00
4) configure_remote_backups;;
5) restore_data_remote;;
6) create_keydrive_master;;
7) create_keydrive_fragment;;
8) format_drive;;
9) remove_backups;;
10) break;;
2015-11-01 11:29:42 +01:00
esac
done
}
function menu_email {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Email Filtering Rules" \
--radiolist $"Choose an operation:" 12 70 5 \
1 $"Add a user to a mailing list" off \
2 $"Add an email rule" off \
3 $"Block/Unblock an email address" off \
4 $"Block/Unblock email with subject text" off \
5 $"Back to main menu" on 2> $data
2015-11-01 11:29:42 +01:00
sel=$?
case $sel in
2015-11-01 11:56:33 +01:00
1) break;;
255) break;;
2015-11-01 11:29:42 +01:00
esac
case $(cat $data) in
1) add_to_mailing_list;;
2) email_rule;;
3) block_unblock_email;;
4) block_unblock_subject;;
5) break;;
esac
done
}
function menu_users {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Manage Users" \
--radiolist $"Choose an operation:" 12 70 5 \
1 $"Add a user" off \
2 $"Delete a user" off \
3 $"Change user password" off \
4 $"Change user ssh public key" off \
5 $"Back to main menu" on 2> $data
2015-11-01 11:29:42 +01:00
sel=$?
case $sel in
2015-11-01 11:56:33 +01:00
1) break;;
255) break;;
2015-11-01 11:29:42 +01:00
esac
case $(cat $data) in
1) add_user;;
2) delete_user;;
3) change_password;;
4) change_ssh_public_key;;
5) break;;
esac
done
}
2015-11-15 13:05:58 +01:00
function menu_hubzilla {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Hubzilla" \
--radiolist $"Choose an operation:" 13 70 4 \
2015-12-18 15:40:46 +01:00
1 $"Set channel directory server" off \
2 $"Renew SSL certificate" off \
3 $"Back to main menu" on 2> $data
2015-11-15 13:05:58 +01:00
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
2015-12-18 15:40:46 +01:00
1) hubzilla_channel_directory_server;;
2) hubzilla_renew_cert;;
3) break;;
2015-11-15 13:05:58 +01:00
esac
done
}
2015-12-03 15:51:18 +01:00
function menu_media {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Media Menu" \
2015-12-03 15:52:31 +01:00
--radiolist $"Choose an operation:" 13 70 3 \
2015-12-03 15:51:18 +01:00
1 $"Attach a drive containing playable media" off \
2 $"Remove a drive containing playable media" off \
3 $"Exit" on 2> $data
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
1) remove-music
attach-music;;
2) remove-music;;
3) break;;
esac
done
}
function menu_irc {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"IRC Menu" \
--radiolist $"Choose an operation:" 13 70 3 \
1 $"Set a password for all IRC users" off \
2 $"Exit" on 2> $data
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
1) irc_set_global_password;;
2) break;;
esac
done
}
2015-11-01 11:29:42 +01:00
function menu_top_level {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
2015-11-27 13:31:28 +01:00
dialog --backtitle $"Freedombone Control Panel" \
--title $"Control Panel" \
--radiolist $"Choose an operation:" 24 70 17 \
2015-11-27 13:31:28 +01:00
1 $"Backup and Restore" off \
2 $"Show SIP Phone Extensions" off \
3 $"Reset Tripwire" off \
4 $"Logging on/off" off \
5 $"Manage Users" off \
6 $"Email Filtering Rules" off \
7 $"Security Settings" off \
8 $"Hubzilla" off \
2015-12-03 15:51:18 +01:00
9 $"Media menu" off \
10 $"IRC menu" off \
11 $"Change the name of this system" off \
12 $"Set the TLS date/time source" off \
13 $"Set a static local IP address" off \
14 $"Check for updates" off \
15 $"Power off the system" off \
16 $"Restart the system" off \
17 $"Exit" on 2> $data
2015-11-01 11:29:42 +01:00
sel=$?
case $sel in
1) exit 1;;
255) exit 1;;
esac
case $(cat $data) in
1) menu_backup_restore;;
2015-11-02 17:28:18 +01:00
2) show_sip_extensions;;
3) reset_tripwire;;
4) logging_on_off;;
5) menu_users;;
6) menu_email;;
7) security_settings;;
2015-11-15 13:05:58 +01:00
8) menu_hubzilla;;
2015-12-03 15:51:18 +01:00
9) menu_media;;
10) menu_irc;;
11) change_system_name;;
12) set_tls_time_source;;
13) set_static_IP;;
14) check_for_updates;;
15) shut_down_system;;
16) restart_system;;
17) break;;
2015-10-31 21:14:23 +01:00
esac
done
}
if [ ! -f $COMPLETION_FILE ]; then
2015-11-27 13:31:28 +01:00
echo $'This command should only be run on an installed Freedombone system'
2015-10-31 21:14:23 +01:00
exit 1
fi
2015-11-03 17:06:19 +01:00
ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
2015-10-31 21:14:23 +01:00
menu_top_level
2015-10-31 21:18:34 +01:00
clear
cat /etc/motd
2015-10-31 21:14:23 +01:00
exit 0