mirror of
https://github.com/Pecusx/piradio-mini.git
synced 2026-05-20 22:33:44 +02:00
Backup and Restore station list added to webinterface.
This commit is contained in:
@@ -48,7 +48,7 @@ input {
|
||||
audio_output {
|
||||
type "alsa"
|
||||
name "Main Alsa"
|
||||
format "41000:16:2"
|
||||
format "44100:16:2"
|
||||
device "hw:0,0" # optional
|
||||
# mixer_type "software" # optional
|
||||
# mixer_device "default" # optional
|
||||
|
||||
+2
-2
@@ -180,8 +180,8 @@ echo $stations;
|
||||
echo '</textarea>';
|
||||
?>
|
||||
<br><button type="submit" name="submit" value="new">Save radio stations list</button>
|
||||
<button type="submit" name="submit" value="old">Restore previous list</button>
|
||||
</form>
|
||||
<button type="submit" name="submit" value="old">Restore previous list</button></form>
|
||||
<a href="s_stlist.php"><button>Backup & Restore station list</button></a>
|
||||
<hr>
|
||||
<a href="changeconf.php?file=restart"><button>PiRadio restart</button></a>
|
||||
<a href="changeconf.php?file=reboot"><button>System reboot</button></a>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="shortcut icon" href="/PiRadio16.gif" />
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<title>PiRadio mini web interface - station list backup and restore</title>
|
||||
</head>
|
||||
<body>
|
||||
<b>PiRadio</b><div id="config"><a href="config.php">config</a></div></br>
|
||||
<hr>
|
||||
<?php
|
||||
$selected = $_FILES['file'];
|
||||
if (isset($selected)) {
|
||||
if ($_FILES["file"]["error"] > 0)
|
||||
{
|
||||
echo "Error: " . $_FILES["file"]["error"] . "<br>";
|
||||
} else {
|
||||
echo "File: ";
|
||||
echo $_FILES["file"]["name"] ;
|
||||
echo " loaded.<br>\r\n";
|
||||
move_uploaded_file($_FILES["file"]["tmp_name"], "/tmp/piradio.stl");
|
||||
$tablica = explode('.', $_FILES["file"]["name"]);
|
||||
$ostatni = count($tablica);
|
||||
if($tablica[$ostatni-1] == 'stl') {
|
||||
$end = shell_exec('sudo ./scripts/restore_stlist.sh unpack');
|
||||
if (file_exists("/tmp/radiod/config/version")) {
|
||||
echo "Setting new station list.<br>\r\n";
|
||||
$end = shell_exec('sudo ./scripts/restore_stlist.sh apply');
|
||||
echo "O.K.<br>\r\n";
|
||||
$end = shell_exec('sudo ./scripts/restart.sh');
|
||||
/* UWAGA! Folder z plikami uruchamianymi przez sudo
|
||||
musi byc dopisany w pliku /etc/sudoers */
|
||||
echo "PiRadio restart in progress.<br>\r\n";
|
||||
echo "Wait!<br>\r\n";
|
||||
echo "<script>\r\n";
|
||||
echo "// redirect to main after 5 seconds\r\n";
|
||||
echo "window.setTimeout(function() {\r\n";
|
||||
echo " window.location.href = 'index.html';\r\n";
|
||||
echo "}, 5000);\r\n";
|
||||
echo "</script>\r\n";
|
||||
} else {
|
||||
echo "This is not PiRadio station list file!!!<br>\r\n";
|
||||
echo "<script>\r\n";
|
||||
echo "// redirect to main after 2 seconds\r\n";
|
||||
echo "window.setTimeout(function() {\r\n";
|
||||
echo " window.location.href = 'index.html';\r\n";
|
||||
echo "}, 2000);\r\n";
|
||||
echo "</script>\r\n";
|
||||
}
|
||||
} else {
|
||||
unlink("/tmp/piradio.stl");
|
||||
echo "This is wrong file!<br>\r\n";
|
||||
echo "<script>\r\n";
|
||||
echo "// redirect to main after 2 seconds\r\n";
|
||||
echo "window.setTimeout(function() {\r\n";
|
||||
echo " window.location.href = 'index.html';\r\n";
|
||||
echo "}, 2000);\r\n";
|
||||
echo "</script>\r\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$end = shell_exec('sudo ./scripts/make_stlist_file.sh');
|
||||
echo "Backup PiRadio station list<br>\r\n";
|
||||
echo "<pre>\r\nClick the 'Backup' button to download station list backup file to your computer.\r\n</pre>\r\n";
|
||||
echo '<a href="piradio.stl"><button>Backup</button></a>';
|
||||
echo "<hr>\r\n";
|
||||
echo "Restore PiRadio station list<br>\r\n";
|
||||
echo "<b><pre>After restoringing PiRadio will be restarted!</pre></b>\r\n";
|
||||
echo "<form action='s_stlist.php' method='post' enctype='multipart/form-data'>\r\n";
|
||||
echo " <pre><label for='file'>Please select a file to restore:</label></pre>\r\n";
|
||||
echo " <input type='hidden' name='MAX_FILE_SIZE' value='30000'>\r\n";
|
||||
echo " <input name='file' type='file' id='file'><br>\r\n";
|
||||
echo " <button type='submit' name='submit'>Restore</button>\r\n";
|
||||
echo "</form>\r\n";
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<a href="changeconf.php?file=restart"><button>PiRadio restart</button></a>
|
||||
<a href="changeconf.php?file=reboot"><button>System reboot</button></a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
# Backup current station list to file
|
||||
|
||||
# prepare temp folder
|
||||
rm -r /tmp/radiod/config
|
||||
mkdir /tmp/radiod/config
|
||||
|
||||
# Version
|
||||
cp /usr/share/radio/version /tmp/radiod/config/
|
||||
|
||||
# PiRadio stationlist file
|
||||
mkdir /tmp/radiod/config/radiod/
|
||||
cp /var/lib/radiod/stationlist /tmp/radiod/config/radiod/
|
||||
|
||||
# MPD playlists
|
||||
mkdir /tmp/radiod/config/playlists/
|
||||
cp /var/lib/mpd/playlists/* /tmp/radiod/config/playlists/
|
||||
|
||||
# Make ready for download file
|
||||
cd /tmp/radiod/config
|
||||
tar -zcf /home/pi/radio/html/piradio.stl *
|
||||
|
||||
# clear temp
|
||||
rm -r /tmp/radiod/config
|
||||
@@ -0,0 +1,29 @@
|
||||
# Restore station list from file
|
||||
|
||||
# Only if 1 params
|
||||
if [ $# = 1 ]; then
|
||||
# Get parameter from commandline
|
||||
|
||||
# "unpack" or "apply"
|
||||
OPTION=$1
|
||||
|
||||
# Unpack or apply
|
||||
if [ ${OPTION} = "unpack" ]; then
|
||||
# prepare temp folder
|
||||
rm -r /tmp/radiod/config
|
||||
mkdir /tmp/radiod/config
|
||||
# Unpack configuration
|
||||
cd /tmp/radiod/config
|
||||
tar -zxf /tmp/piradio.stl
|
||||
# remove station list backup file
|
||||
rm /tmp/piradio.stl
|
||||
elif [ ${OPTION} = "apply" ]; then
|
||||
# PiRadio statiolist file
|
||||
cp /tmp/radiod/config/radiod/stationlist /var/lib/radiod/
|
||||
# MPD playlists
|
||||
rm /var/lib/mpd/playlists/*
|
||||
cp /tmp/radiod/config/playlists/* /var/lib/mpd/playlists/
|
||||
# clear temp
|
||||
rm -r /tmp/radiod/config
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user