Skip to content
Snippets Groups Projects
Commit 7d782933 authored by Bob Mottram's avatar Bob Mottram
Browse files

Ability to initiate an upgrade from webadmin

parent 50e79ed4
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ FIREWALL_DOMAINS=/root/${PROJECT_NAME}-firewall-domains.cfg ...@@ -52,6 +52,7 @@ FIREWALL_DOMAINS=/root/${PROJECT_NAME}-firewall-domains.cfg
local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local
webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin" webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin"
upgrade_file="$webadmin_install_dir/.upgrade.txt"
language_file="$webadmin_install_dir/.language.txt" language_file="$webadmin_install_dir/.language.txt"
system_monitor_file="$webadmin_install_dir/.system_monitor.txt" system_monitor_file="$webadmin_install_dir/.system_monitor.txt"
dynamic_dns_file="$webadmin_install_dir/.dynamicdns.txt" dynamic_dns_file="$webadmin_install_dir/.dynamicdns.txt"
...@@ -75,6 +76,7 @@ installer_script=/root/.fbone_installer.sh ...@@ -75,6 +76,7 @@ installer_script=/root/.fbone_installer.sh
webadmin_prev_hour=99 webadmin_prev_hour=99
# temporary backup and restore scripts # temporary backup and restore scripts
upgrade_script=/root/.webadmin_upgrade.sh
backup_script=/root/.webadmin_backup.sh backup_script=/root/.webadmin_backup.sh
backup_keys_script=/root/.webadmin_backup_keys.sh backup_keys_script=/root/.webadmin_backup_keys.sh
restore_script=/root/.webadmin_restore.sh restore_script=/root/.webadmin_restore.sh
...@@ -574,6 +576,7 @@ function check_for_existing_processes { ...@@ -574,6 +576,7 @@ function check_for_existing_processes {
echo '}'; echo '}';
echo ''; echo '';
echo 'exit_if_process_is_running fbone_installer.sh'; echo 'exit_if_process_is_running fbone_installer.sh';
echo 'exit_if_process_is_running webadmin_upgrade.sh';
echo 'exit_if_process_is_running webadmin_format.sh'; echo 'exit_if_process_is_running webadmin_format.sh';
echo 'exit_if_process_is_running webadmin_backup.sh'; echo 'exit_if_process_is_running webadmin_backup.sh';
echo 'exit_if_process_is_running webadmin_backup_keys.sh'; echo 'exit_if_process_is_running webadmin_backup_keys.sh';
...@@ -1288,6 +1291,26 @@ function webadmin_change_password { ...@@ -1288,6 +1291,26 @@ function webadmin_change_password {
rm "$change_password_file" rm "$change_password_file"
} }
function webadmin_upgrade {
if [ -f "$upgrade_file" ]; then
rm "$upgrade_file"
check_for_existing_processes $upgrade_script
{ echo "echo \"Beginning webadmin upgrade \$(date)\" > $webadmin_install_dir/upgrade.txt";
echo "chown www-data:www-data $webadmin_install_dir/upgrade.txt";
echo '';
echo "/usr/local/bin/${PROJECT_NAME}-upgrade >> $webadmin_install_dir/upgrade.txt";
echo '';
echo "chown www-data:www-data $webadmin_install_dir/upgrade.txt";
echo '';
echo "exit 0"; } >> $upgrade_script
chmod +x $upgrade_script
# run in a separate process
./$upgrade_script &
fi
}
function reset_shutdown { function reset_shutdown {
if [ -f "$shutdown_file" ]; then if [ -f "$shutdown_file" ]; then
rm "$shutdown_file" rm "$shutdown_file"
...@@ -1620,6 +1643,7 @@ do ...@@ -1620,6 +1643,7 @@ do
backup_and_restore backup_and_restore
backup_and_restore_keys backup_and_restore_keys
add_remove_users add_remove_users
webadmin_upgrade
install_apps_from_webadmin install_apps_from_webadmin
sleep 1 sleep 1
remove_apps_from_webadmin remove_apps_from_webadmin
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<br><br> <br><br>
<form action="reset.php" method="post"> <form action="reset.php" method="post">
<input type="submit" name="submitupgrade" value="Upgrade" /><br><br>
<input type="submit" name="submitshutdown" value="Shutdown" /><br><br> <input type="submit" name="submitshutdown" value="Shutdown" /><br><br>
<input type="submit" name="submitreset" value="Reset" /><br><br> <input type="submit" name="submitreset" value="Reset" /><br><br>
<input type="submit" name="submitresetcancel" value="Cancel" /> <input type="submit" name="submitresetcancel" value="Cancel" />
......
<!DOCTYPE html>
<html>
<head>
<style>
#headerpic {
width: 60%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 220px;
}
.header {
text-align: center;
padding: 32px;
}
#iconpic {
width: 20%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 120px;
}
.appurl {
color: grey;
font-size: 100%;
}
.appdesc {
color: black;
font-size: 65%;
}
button {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
a {
text-decoration: none;
color: black;
}
button:hover, a:hover {
opacity: 0.7;
}
</style>
</head>
<body>
<div class="header">
<a href="index.html"><img id="headerpic" class="img-responsive" src="images/logo.png"></a>
<h3>An upgrade is scheduled</h3>
<h3>Systems may be temporarily unavailable in the next few minutes</h3>
<p>Upgrades happen automatically. You don't need to start them manually like this, except in rare circumstances.</p>
<br>
<form action="index.html">
<input type="submit" value="Go Back" />
</form>
</div>
</body>
</html>
...@@ -4,8 +4,16 @@ ...@@ -4,8 +4,16 @@
$output_filename = "settings.html"; $output_filename = "settings.html";
if (isset($_POST['submitupgrade'])) {
$reset_file = fopen(".upgrade.txt", "w") or die("Unable to write to upgrade file");
fwrite($reset_file, "upgrade");
fclose($reset_file);
$output_filename = "upgrade.html";
}
if (isset($_POST['submitreset'])) { if (isset($_POST['submitreset'])) {
$reset_file = fopen(".reset.txt", "w") or die("Unable to write to domain file"); $reset_file = fopen(".reset.txt", "w") or die("Unable to write to reset file");
fwrite($reset_file, "reset"); fwrite($reset_file, "reset");
fclose($reset_file); fclose($reset_file);
...@@ -13,7 +21,7 @@ if (isset($_POST['submitreset'])) { ...@@ -13,7 +21,7 @@ if (isset($_POST['submitreset'])) {
} }
if (isset($_POST['submitshutdown'])) { if (isset($_POST['submitshutdown'])) {
$shutdown_file = fopen(".shutdown.txt", "w") or die("Unable to write to domain file"); $shutdown_file = fopen(".shutdown.txt", "w") or die("Unable to write to shutdown file");
fwrite($shutdown_file, "shutdown"); fwrite($shutdown_file, "shutdown");
fclose($shutdown_file); fclose($shutdown_file);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment