adding crontab editor

This commit is contained in:
mcguirepr89
2022-01-24 18:38:45 -05:00
parent c3fb5c2a36
commit cebcff5768
4 changed files with 54 additions and 14 deletions
+1
View File
@@ -140,6 +140,7 @@ if(isset($_SESSION['success'])){
<br>
<br>
<button type="text"><a href="config.php">Basic Settings</a></button>
<button type="text"><a href="edit_crontab.php">Edit the Crontab</a></button>
</form>
</div>
</div>
+46
View File
@@ -0,0 +1,46 @@
<?php
// configuration
$url = 'edit_crontab.php';
$file = '/etc/crontab';
// check if form has been submitted
if (isset($_POST['text']))
{
// save the text contents
file_put_contents($file, $_POST['text']);
// redirect to form again
header(sprintf('Location: %s', $url));
printf('<a href="%s">Moved</a>.', htmlspecialchars($url));
exit();
}
// read the textfile
$text = file_get_contents($file);
?>
<!-- HTML form -->
<head>
<style>
* {
font-family: 'monospace';
}
a {
text-decoration: none;
color: black;
}
form {
text-align: center;
}
</style>
<body style="background-color:rgb(119, 196, 135);">
<form style="height:95%" action="" method="post">
<input style="margin-left:-150px;" type="submit" value="Update" />
<input type="reset" value="Discard Changes" />
<button type="text"><a href="advanced.php">Back</a></button><br>
<textarea name="text" style="font-size:large;width:100%;height:95%;"><?php echo htmlspecialchars($text) ?></textarea>
</form>
</body>
+3 -7
View File
@@ -505,13 +505,9 @@ install_nomachine() {
install_cleanup_cron() {
echo "Installing the cleanup.cron"
if ! crontab -u ${USER} -l &> /dev/null;then
crontab -u ${USER} $(dirname ${my_dir})/templates/cleanup.cron &> /dev/null
else
crontab -u ${USER} -l > ${tmpfile}
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${tmpfile}
crontab -u ${USER} "${tmpfile}" &> /dev/null
fi
echo $(dirname ${my_dir})/templates/cleanup.cron >> /etc/crontab
chown root:pi /etc/crontab
chmod g+rw /etc/crontab
}
install_selected_services() {
+4 -7
View File
@@ -500,13 +500,10 @@ install_nomachine() {
install_cleanup_cron() {
echo "Installing the cleanup.cron"
if ! crontab -u ${USER} -l &> /dev/null;then
crontab -u ${USER} $(dirname ${my_dir})/templates/cleanup.cron &> /dev/null
else
crontab -u ${USER} -l > ${tmpfile}
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${tmpfile}
crontab -u ${USER} "${tmpfile}" &> /dev/null
fi
echo $(dirname ${my_dir})/templates/cleanup.cron >> /etc/crontab
chown root:pi /etc/crontab
chmod g+rw /etc/crontab
}
install_selected_services() {