added a sudoers file; refined handling of success/error

This commit is contained in:
eclipse 2023-09-26 22:16:45 +02:00
parent b933ad4fc9
commit 970c5e1df6
3 changed files with 9 additions and 3 deletions

2
conf/restarter Normal file
View File

@ -0,0 +1,2 @@
# sudoers entry for package restarter
www-data unterdemradar=NOPASSWD: /usr/bin/systemctl restart minidlna.service

View File

@ -20,8 +20,8 @@ console.log(query);
</script>
</head>
<body>
<!-- <button type=button onClick="restart('sudo systemctl restart minidlna.service')">MiniDLNA</button> -->
<button type=button onClick="restart('ls -al')">MiniDLNA</button>
<!-- PHP built-in web server: php -S [IP]:[port] -t [path]</pre></p> -->
<div id="result">
</div>
</body>

View File

@ -14,6 +14,10 @@
}
// execute shell command
exec($command, $output, $exitcode);
echo "Output is <pre>", join("<br>", $output), "</pre><br>";
echo "Exit code is ", $exitcode;
echo "Output is <pre>", join("<br>", $output), "</pre><br>";//DEBUG
if ( $exitcode == "0" ) {
echo "Success";
} else {
echo "Command failed with exit code", $exitcode;
}
?>