mirror of
https://github.com/unraid/webgui.git
synced 2026-01-07 10:10:05 -06:00
- Create page for Local Console
- Create console script - Create rc.keymap and modify default ot be compatible with local console settings - Change rc.setterm to be compatible with local console settings - Change rc.local to be compatible with persistent bash history
This commit is contained in:
108
emhttp/plugins/dynamix/Console.page
Normal file
108
emhttp/plugins/dynamix/Console.page
Normal file
@@ -0,0 +1,108 @@
|
||||
Menu="UserPreferences"
|
||||
Type="xmenu"
|
||||
Title="Console Settings"
|
||||
Icon="terminal"
|
||||
Tag="terminal"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
// selected keyboard layouts
|
||||
$keymaps = [
|
||||
'by' => 'Belarusian',
|
||||
'be-latin1' => 'Belgium (French)',
|
||||
'br-abnt' => 'Brazilian',
|
||||
'cz' => 'Czech',
|
||||
'dk' => 'Danish',
|
||||
'nl' => 'Dutch',
|
||||
'uk' => 'English (United Kingdom)',
|
||||
'us' => 'English (United States)',
|
||||
'es' => 'Español',
|
||||
'et' => 'Estonian',
|
||||
'fi' => 'Finnish',
|
||||
'fr' => 'French',
|
||||
'de-latin1-nodeadkeys' => 'German',
|
||||
'gr' => 'Greek',
|
||||
'hu' => 'Hungarian',
|
||||
'is-latin1' => 'Icelandic',
|
||||
'it' => 'Italian',
|
||||
'il' => 'Israelian',
|
||||
'lt' => 'Lithuanian',
|
||||
'mk' => 'Macedonian',
|
||||
'no' => 'Norwegian',
|
||||
'pl' => 'Polish',
|
||||
'pt' => 'Portuguese',
|
||||
'ro' => 'Romanian',
|
||||
'ru' => 'Russian',
|
||||
'sk-qwertz' => 'Slovakian',
|
||||
'se-latin1' => 'Swedish',
|
||||
'de_CH-latin1' => 'Swiss (German)',
|
||||
'fr_CH-latin1' => 'Swiss (French)',
|
||||
'tr_q-latin5' => 'Turkish'
|
||||
];
|
||||
|
||||
// time-out values in minutes
|
||||
$minutes = [1,5,10,15,30,45,60];
|
||||
?>
|
||||
<script>
|
||||
function prepareConsole(form) {
|
||||
// preset keyboard layout, screen blank time and persistent bash history
|
||||
$(form).find('[name="#arg[1]"]').val(form.keyboard_layout.value);
|
||||
$(form).find('[name="#arg[2]"]').val(form.screen_blank.value);
|
||||
$(form).find('[name="#arg[3]"]').val(form.persist_bash_history.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<form markdown="1" name="console_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareConsole(this)">
|
||||
<input type="hidden" name="#file" value="dynamix/dynamix.cfg">
|
||||
<input type="hidden" name="#section" value="console">
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/console">
|
||||
<input type="hidden" name="#arg[1]" value="">
|
||||
<input type="hidden" name="#arg[2]" value="">
|
||||
<input type="hidden" name="#arg[3]" value="">
|
||||
|
||||
_(Local keyboard layout)_:
|
||||
: <select name="keyboard_layout">
|
||||
<?foreach ($keymaps as $keymap => $text) echo mk_option($console['keyboard_layout'], $keymap, $text, (!isset($console['keyboard_layout']) && $keymap == 'us' ? 'selected' : ''))?>
|
||||
</select>
|
||||
|
||||
<blockquote class="inline_help">
|
||||
<p>Select your default keymap for the local console (not the web Terminal).<br/></p>
|
||||
</blockquote>
|
||||
|
||||
_(Local screen blank time)_:
|
||||
: <select name="screen_blank" class="narrow">
|
||||
<option value="default" <?php echo (!isset($console['screen_blank']) || $console['screen_blank'] == 'default') ? 'selected' : ''; ?>>Default - 15</option>
|
||||
<option value="disabled" <?php echo ($console['screen_blank'] == 'disabled') ? 'selected' : ''; ?>>Disabled - 0</option>
|
||||
<?php foreach ($minutes as $minute) echo mk_option($console['screen_blank'], $minute, $minute, ($console['screen_blank'] == $minute) ? 'selected' : ''); ?>
|
||||
</select> _(minutes)_
|
||||
|
||||
<blockquote class="inline_help">
|
||||
<p><b>Default:</b> 'Default' will set the blank timeout to 15 minutes and powersave to 60 minutes.<br/>
|
||||
<b>Disabled:</b> 'Disabled' will disable the blank and powersave timeout.<br/>
|
||||
<b>All other values:</b> Will set the blank timout to the selected value and disable the powersave timeout.</p>
|
||||
</blockquote>
|
||||
|
||||
_(Persistent Bash History)_:
|
||||
: <select name="persist_bash_history" class="narrow">
|
||||
<option value="0" <?php echo ($console['persist_bash_history'] == 0) ? 'selected' : ''; ?>>No</option>
|
||||
<option value="1" <?php echo ($console['persist_bash_history'] == 1) ? 'selected' : ''; ?>>Yes</option>
|
||||
</select>
|
||||
|
||||
<blockquote class="inline_help">
|
||||
<p>If set to 'Yes' the bash history will persist reboots, set to 'No' to disable.<br/><b>ATTENTION:</b> The bash history will be written to the USB Boot device so this will introduce higher wear and tear!<br/><b>Note:</b> Disabling and Enabling will remove the entire bash history.</p>
|
||||
</blockquote>
|
||||
|
||||
|
||||
: <input type="submit" name="#apply" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</form>
|
||||
25
emhttp/plugins/dynamix/scripts/console
Executable file
25
emhttp/plugins/dynamix/scripts/console
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Load keyboard layout for local console
|
||||
loadkeys -q $1
|
||||
|
||||
# Set screenblank and powersave for local console
|
||||
if [[ $2 =~ ^[0-9]+$ ]]; then
|
||||
TERM=linux setterm --blank=$2 --powersave off >/dev/console
|
||||
elif [[ $2 == disabled ]]; then
|
||||
TERM=linux setterm --blank=0 --powersave off >/dev/console
|
||||
else
|
||||
TERM=linux setterm --blank 15 --powersave powerdown --powerdown 60 >/dev/console
|
||||
fi
|
||||
|
||||
# Enable or disable persistent bash history
|
||||
if [[ $3 == 1 ]]; then
|
||||
if [[ ! -d /boot/config/history ]]; then
|
||||
mkdir -p /boot/config/history
|
||||
fi
|
||||
rm -f /root/.bash_history
|
||||
touch /boot/config/history/bash_history
|
||||
ln -s /boot/config/history/bash_history /root/.bash_history
|
||||
else
|
||||
rm -f /boot/config/history/bash_history /root/.bash_history
|
||||
touch /root/.bash_history
|
||||
fi
|
||||
9
etc/rc.d/rc.keymap
Executable file
9
etc/rc.d/rc.keymap
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Load a keyboard map. More maps are in /usr/share/kbd/keymaps.
|
||||
|
||||
# Read Unraid config file and set kayboard layout if found.
|
||||
KBD_LAYOUT=$(grep "keyboard_layout" /boot/config/plugins/dynamix/dynamix.cfg 2>/dev/null | cut -d'=' -f2 | sed 's/"//g')
|
||||
if [[ ! -z $KBD_LAYOUT ]]; then
|
||||
loadkeys $KBD_LAYOUT >/dev/null 2>&1
|
||||
fi
|
||||
@@ -150,6 +150,17 @@ for LANGUAGE in $CONFIG/plugins/lang-*.xml; do
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
# Enable persistent bash history
|
||||
PERSISTENT_BASH_HISTORY=$(grep "persist_bash_history" /boot/config/plugins/dynamix/dynamix.cfg 2>/dev/null | cut -d'=' -f2 | sed 's/"//g')
|
||||
if [[ $PERSISTENT_BASH_HISTORY == 1 ]]; then
|
||||
if [[ ! -d /boot/config/history ]]; then
|
||||
mkdir -p /boot/config/history
|
||||
fi
|
||||
rm -f /root/.bash_history
|
||||
touch /boot/config/history/bash_history
|
||||
ln -s /boot/config/history/bash_history /root/.bash_history
|
||||
fi
|
||||
|
||||
# Invoke the 'go' script
|
||||
if [[ -f $CONFIG/go ]]; then
|
||||
log "Starting go script"
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# script: rc.setterm
|
||||
#
|
||||
# This file provides the command line for the setterm utility to set the
|
||||
# terminal attributes (primarily used for screen blanking and power management).
|
||||
# terminal attributes (primarily used for screen blanking and power
|
||||
# management).
|
||||
#
|
||||
# LimeTech - modified for Unraid OS
|
||||
# Bergware - modified for Unraid OS, October 2023
|
||||
|
||||
# Screen blanks after 15 minutes idle time, and powers down in one hour
|
||||
# if the kernel supports APM or ACPI power management (default setting):
|
||||
setterm -blank 15 -powersave powerdown -powerdown 60
|
||||
# Read Unraid config file and set timout or fall back to default
|
||||
SCREEN_BLANK=$(grep "screen_blank" /boot/config/plugins/dynamix/dynamix.cfg 2>/dev/null | cut -d'=' -f2 | sed 's/"//g')
|
||||
if [[ $SCREEN_BLANK =~ ^[0-9]+$ ]]; then
|
||||
setterm --blank $SCREEN_BLANK --powersave off
|
||||
elif [[ $SCREEN_BLANK == disabled ]]; then
|
||||
setterm --blank=0 --powersave off
|
||||
else
|
||||
# Screen blanks after 15 minutes idle time, and powers down in one hour
|
||||
# if the kernel supports APM or ACPI power management (default setting):
|
||||
setterm --blank 15 --powersave powerdown --powerdown 60
|
||||
fi
|
||||
|
||||
# Screen does not blank or use power management features:
|
||||
# setterm -blank 0 -powersave off -powerdown 0
|
||||
#setterm -blank 0 -powersave off -powerdown 0
|
||||
|
||||
Reference in New Issue
Block a user