mirror of
https://github.com/unraid/webgui.git
synced 2026-02-26 12:18:56 -06:00
Merge pull request #1454 from bergware/master
scripts dutchification - batch 2
This commit is contained in:
@@ -15,11 +15,12 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
// add translations
|
||||
$_SERVER['REQUEST_URI'] = 'settings';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$save = false;
|
||||
$disks = parse_ini_file('state/disks.ini',true);
|
||||
$newkey = parse_ini_file('state/var.ini')['luksKeyfile'];
|
||||
$oldkey = str_replace('keyfile','oldfile',$newkey);
|
||||
$newkey = parse_ini_file('state/var.ini')['luksKeyfile'] ?: '/root/keyfile';
|
||||
$oldkey = dirname($newkey).'/oldfile';
|
||||
$delkey = !is_file($newkey);
|
||||
$crypto = [];
|
||||
|
||||
@@ -45,7 +46,7 @@ function removeKey($key,$disk) {
|
||||
if ($match && preg_match($match,$row)) $slots++;
|
||||
}
|
||||
pclose($dump);
|
||||
if ($slots > 1) exec("cryptsetup luksRemoveKey /dev/$disk $key 1>/dev/null 2>&1");
|
||||
if ($slots > 1) exec("cryptsetup luksRemoveKey /dev/$disk $key &>/dev/null");
|
||||
}
|
||||
function diskname($name) {
|
||||
global $disks;
|
||||
@@ -54,20 +55,20 @@ function diskname($name) {
|
||||
}
|
||||
function reply($text,$type) {
|
||||
global $oldkey,$newkey,$delkey;
|
||||
$reply = $_POST['#reply'];
|
||||
$reply = _var($_POST,'#reply');
|
||||
if (realpath(dirname($reply))=='/var/tmp') file_put_contents($reply,$text."\0".$type);
|
||||
delete_file($oldkey);
|
||||
if ($_POST['newinput']=='text' || $delkey) delete_file($newkey);
|
||||
if (_var($_POST,'newinput','text')=='text' || $delkey) delete_file($newkey);
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($_POST['oldinput'])) {
|
||||
switch ($_POST['oldinput']) {
|
||||
case 'text':
|
||||
file_put_contents($oldkey,base64_decode($_POST['oldluks']));
|
||||
file_put_contents($oldkey,base64_decode(_var($_POST,'oldluks')));
|
||||
break;
|
||||
case 'file':
|
||||
file_put_contents($oldkey,base64_decode(explode(';base64,',$_POST['olddata'])[1]));
|
||||
file_put_contents($oldkey,base64_decode(explode(';base64,',_var($_POST,'olddata','x;base64,'))[1]));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -76,7 +77,7 @@ if (isset($_POST['oldinput'])) {
|
||||
|
||||
if (is_file($oldkey)) {
|
||||
$disk = $crypto[0]; // check first disk only (key is the same for all disks)
|
||||
exec("cryptsetup luksOpen --test-passphrase --key-file $oldkey /dev/$disk 1>/dev/null 2>&1",$none,$error);
|
||||
exec("cryptsetup luksOpen --test-passphrase --key-file $oldkey /dev/$disk &>/dev/null",$null,$error);
|
||||
} else $error = 1;
|
||||
|
||||
if ($error > 0) reply(_('Incorrect existing key'),'warning');
|
||||
@@ -84,20 +85,25 @@ if ($error > 0) reply(_('Incorrect existing key'),'warning');
|
||||
if (isset($_POST['newinput'])) {
|
||||
switch ($_POST['newinput']) {
|
||||
case 'text':
|
||||
file_put_contents($newkey,base64_decode($_POST['newluks']));
|
||||
file_put_contents($newkey,base64_decode(_var($_POST,'newluks')));
|
||||
$luks = 'luksKey';
|
||||
$data = _var($_POST,'newluks');
|
||||
break;
|
||||
case 'file':
|
||||
file_put_contents($newkey,base64_decode(explode(';base64,',$_POST['newdata'])[1]));
|
||||
file_put_contents($newkey,base64_decode(explode(';base64,',_var($_POST,'newdata','x;base64,'))[1]));
|
||||
$luks = 'luksKey=&luksKeyfile';
|
||||
$data = $newkey;
|
||||
break;
|
||||
}
|
||||
$good = $bad = [];
|
||||
foreach ($crypto as $disk) {
|
||||
exec("cryptsetup luksAddKey --key-file $oldkey /dev/$disk $newkey 1>/dev/null 2>&1",$none,$error);
|
||||
exec("cryptsetup luksAddKey --key-file $oldkey /dev/$disk $newkey &>/dev/null",$null,$error);
|
||||
if ($error==0) $good[] = $disk; else $bad[] = diskname($disk);
|
||||
}
|
||||
if (count($bad)==0) {
|
||||
// all okay, remove the old key
|
||||
foreach ($good as $disk) removeKey($oldkey,$disk);
|
||||
exec("emcmd 'changeDisk=apply&$luks=$data'");
|
||||
reply(_('Key successfully changed'),'success');
|
||||
} else {
|
||||
// something went wrong, restore key
|
||||
|
||||
@@ -7,31 +7,42 @@
|
||||
# LimeTech - modified for Unraid OS
|
||||
# Bergware - modified for Unraid OS, October 2023
|
||||
|
||||
DAEMON="ACPI daemon"
|
||||
DAEMON="ACPI power management daemon"
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
|
||||
acpid_running(){
|
||||
ps axc | grep -q ' acpid'
|
||||
}
|
||||
|
||||
acpid_start(){
|
||||
log "Starting $DAEMON..."
|
||||
local REPLY
|
||||
if [[ -x /usr/sbin/acpid && -d /proc/acpi ]]; then
|
||||
run /usr/sbin/acpid
|
||||
REPLY="Started"
|
||||
if acpid_running; then
|
||||
REPLY="Already started"
|
||||
else
|
||||
REPLY="Failed"
|
||||
if [[ -d /proc/acpi ]]; then
|
||||
run /usr/sbin/acpid
|
||||
if acpid_running; then REPLY="Started"; else REPLY="Failed"; fi
|
||||
else
|
||||
REPLY="No ACPI present"
|
||||
fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
}
|
||||
|
||||
acpid_stop(){
|
||||
log "Stopping $DAEMON..."
|
||||
if [[ -r /var/run/acpid.pid ]]; then
|
||||
kill $(cat /var/run/acpid.pid)
|
||||
local REPLY
|
||||
if ! acpid_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
killall acpid
|
||||
run kill $(cat /var/run/acpid.pid 2>/dev/null)
|
||||
run killall acpid
|
||||
if ! acpid_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... Stopped."
|
||||
log "$DAEMON... $REPLY."
|
||||
}
|
||||
|
||||
acpid_restart(){
|
||||
@@ -41,6 +52,15 @@ acpid_restart(){
|
||||
acpid_start
|
||||
}
|
||||
|
||||
acpid_status(){
|
||||
if acpid_running; then
|
||||
echo "$DAEMON is currently running."
|
||||
else
|
||||
echo "$DAEMON is not running."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
acpid_start
|
||||
@@ -51,8 +71,11 @@ case "$1" in
|
||||
'restart')
|
||||
acpid_restart
|
||||
;;
|
||||
'status')
|
||||
acpid_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $BASENAME start|stop|restart"
|
||||
echo "Usage: $BASENAME start|stop|restart|status"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
||||
|
||||
@@ -93,6 +93,27 @@ ip_forward_restart(){
|
||||
ip_forward_start
|
||||
}
|
||||
|
||||
ip_forward_status(){
|
||||
if [[ -f $SYSTEM/ipv4/ip_forward ]]; then
|
||||
if [[ $(cat $SYSTEM/ipv4/ip_forward) == 1 ]]; then
|
||||
echo "IPv4 packet forwarding is enabled."
|
||||
else
|
||||
echo "IPv4 packet forwarding is disabled."
|
||||
fi
|
||||
else
|
||||
echo "IPv4 packet forwarding is not present."
|
||||
fi
|
||||
if [[ -f $SYSTEM/ipv6/conf/all/forwarding ]]; then
|
||||
if [[ $(cat $SYSTEM/ipv6/conf/all/forwarding) == 1 ]]; then
|
||||
echo "IPv6 packet forwarding is enabled."
|
||||
else
|
||||
echo "IPv6 packet forwarding is disabled."
|
||||
fi
|
||||
else
|
||||
echo "IPv6 packet forwarding is not present."
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
ip_forward_start
|
||||
@@ -103,8 +124,11 @@ case "$1" in
|
||||
'restart')
|
||||
ip_forward_restart
|
||||
;;
|
||||
'status')
|
||||
ip_forward_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $BASENAME start|stop|restart"
|
||||
echo "Usage: $BASENAME start|stop|restart|status"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
||||
|
||||
@@ -49,10 +49,13 @@ mcelog_start(){
|
||||
if mcelog_running; then
|
||||
REPLY="Already started"
|
||||
else
|
||||
# ignorance is bliss I guess
|
||||
$MCELOG --is-cpu-supported &>/dev/null
|
||||
$MCELOG --daemon $MCELOG_OPTIONS
|
||||
if mcelog_running; then REPLY="Started"; else REPLY="Failed"; fi
|
||||
# check cpu support (Intel)
|
||||
if $MCELOG --is-cpu-supported &>/dev/null; then
|
||||
$MCELOG --daemon $MCELOG_OPTIONS
|
||||
if mcelog_running; then REPLY="Started"; else REPLY="Failed"; fi
|
||||
else
|
||||
REPLY="Skipped"
|
||||
fi
|
||||
fi
|
||||
elif [[ -f $TRIGGER ]]; then
|
||||
echo $MCELOG > $TRIGGER
|
||||
|
||||
Reference in New Issue
Block a user