mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 05:13:01 +02:00
setup: add support for easily switching system boot mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
#set -x
|
||||
|
||||
mode=/mnt/cfg/infix/.use_etc
|
||||
boot=/tmp/.boot_mode
|
||||
if [ -f $boot ]; then
|
||||
current=$(cat $boot)
|
||||
else
|
||||
current="unknown"
|
||||
fi
|
||||
m=on
|
||||
n=off
|
||||
|
||||
select_mode()
|
||||
{
|
||||
if [ -f $mode ]; then
|
||||
m=off
|
||||
n=on
|
||||
fi
|
||||
|
||||
exec 3>&1
|
||||
selection=$(dialog --erase-on-exit --no-tags \
|
||||
--hline "Arrow keys + space to select, enter to confirm" \
|
||||
--backtitle "Select Operating Mode" \
|
||||
--title "Select Operating Mode" \
|
||||
--radiolist "System currently runs in: $current mode" 10 60 1 \
|
||||
"1" "Managed NETCONF, XML datastore" "$m" \
|
||||
"2" "Native Linux, /etc datastore" "$n" \
|
||||
2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
case $exit_status in
|
||||
1) # cancel
|
||||
exit 0
|
||||
;;
|
||||
255) # escape
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
usage:
|
||||
chom [-h] [etc | netconf]
|
||||
|
||||
options:
|
||||
-h Show this help text
|
||||
|
||||
arguments:
|
||||
etc Change to Linux native mode, /etc
|
||||
netconf Change to NETCONF mode, XML
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
net* | xml)
|
||||
selection=1
|
||||
;;
|
||||
nat* | etc*)
|
||||
selection=2
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$selection" ]; then
|
||||
use_dialog=1
|
||||
select_mode
|
||||
fi
|
||||
|
||||
case $selection in
|
||||
1)
|
||||
rm -f $mode 2>/dev/null
|
||||
grep -qi netconf $boot 2>/dev/null && exit 0
|
||||
result="Manageed NETCONF"
|
||||
;;
|
||||
2)
|
||||
touch $mode 2>/dev/null
|
||||
grep -qi native $boot 2>/dev/null && exit 0
|
||||
result="Native Linux, /etc"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$use_dialog" ]; then
|
||||
dialog --erase-on-exit --cr-wrap --title "Activate Mode Change?" --yesno "\n Reboot to $result mode now?" 8 50
|
||||
if [ $? -eq 0 ]; then
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Remember to reboot later to activate the change."
|
||||
exit 0
|
||||
@@ -60,6 +60,8 @@ menu:system:System:System Settings
|
||||
exec:_Enable service:edit:initctl enable ~Enter name of service (filename) to enable:~
|
||||
exec:_Disable service:edit:initctl disable ~Enter name of service (filename) to disable:~
|
||||
nop
|
||||
exec:_Change Operating Mode::chom
|
||||
nop
|
||||
exit:_Main menu..
|
||||
|
||||
menu:tools:Tools:Tools
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#
|
||||
# Run-time configuration file for dialog
|
||||
#
|
||||
# Automatically generated by "dialog --create-rc <file>"
|
||||
#
|
||||
#
|
||||
# Types of values:
|
||||
#
|
||||
# Number - <number>
|
||||
# String - "string"
|
||||
# Boolean - <ON|OFF>
|
||||
# Attribute - (foreground,background,highlight?,underline?,reverse?)
|
||||
|
||||
# Set aspect-ration.
|
||||
aspect = 0
|
||||
|
||||
# Set separator (for multiple widgets output).
|
||||
separate_widget = ""
|
||||
|
||||
# Set tab-length (for textbox tab-conversion).
|
||||
tab_len = 0
|
||||
|
||||
# Make tab-traversal for checklist, etc., include the list.
|
||||
visit_items = OFF
|
||||
|
||||
# Shadow dialog boxes? This also turns on color.
|
||||
use_shadow = ON
|
||||
|
||||
# Turn color support ON or OFF
|
||||
use_colors = ON
|
||||
|
||||
# Screen color
|
||||
screen_color = (WHITE,BLUE,OFF)
|
||||
|
||||
# Shadow color
|
||||
shadow_color = (BLACK,BLACK,OFF)
|
||||
|
||||
# Dialog box color
|
||||
dialog_color = (BLACK,CYAN,OFF)
|
||||
|
||||
# Dialog box title color
|
||||
title_color = (BLACK,CYAN,ON)
|
||||
|
||||
# Dialog box border color
|
||||
border_color = dialog_color
|
||||
|
||||
# Active button color
|
||||
button_active_color = (CYAN,BLACK,ON)
|
||||
|
||||
# Inactive button color
|
||||
button_inactive_color = dialog_color
|
||||
|
||||
# Active button key color
|
||||
button_key_active_color = (WHITE,BLACK,ON)
|
||||
|
||||
# Inactive button key color
|
||||
button_key_inactive_color = (WHITE,CYAN,ON)
|
||||
|
||||
# Active button label color
|
||||
button_label_active_color = button_active_color
|
||||
|
||||
# Inactive button label color
|
||||
button_label_inactive_color = dialog_color
|
||||
|
||||
# Input box color
|
||||
inputbox_color = (BLACK,CYAN,OFF)
|
||||
|
||||
# Input box border color
|
||||
inputbox_border_color = inputbox_color
|
||||
|
||||
# Search box color
|
||||
searchbox_color = inputbox_color
|
||||
|
||||
# Search box title color
|
||||
searchbox_title_color = (BLUE,WHITE,ON)
|
||||
|
||||
# Search box border color
|
||||
searchbox_border_color = (WHITE,WHITE,ON)
|
||||
|
||||
# File position indicator color
|
||||
position_indicator_color = searchbox_title_color
|
||||
|
||||
# Menu box color
|
||||
menubox_color = dialog_color
|
||||
|
||||
# Menu box border color
|
||||
menubox_border_color = dialog_color
|
||||
|
||||
# Item color
|
||||
item_color = inputbox_color
|
||||
|
||||
# Selected item color
|
||||
item_selected_color = button_key_active_color
|
||||
|
||||
# Tag color
|
||||
tag_color = button_inactive_color
|
||||
|
||||
# Selected tag color
|
||||
tag_selected_color = (CYAN,BLACK,OFF)
|
||||
|
||||
# Tag key color
|
||||
tag_key_color = button_key_inactive_color
|
||||
|
||||
# Selected tag key color
|
||||
tag_key_selected_color = (WHITE,BLACK,ON)
|
||||
|
||||
# Check box color
|
||||
check_color = inputbox_color
|
||||
|
||||
# Selected check box color
|
||||
check_selected_color = button_key_active_color
|
||||
|
||||
# Up arrow color
|
||||
uarrow_color = (GREEN,WHITE,ON)
|
||||
|
||||
# Down arrow color
|
||||
darrow_color = uarrow_color
|
||||
|
||||
# Item help-text color
|
||||
itemhelp_color = (WHITE,BLACK,OFF)
|
||||
|
||||
# Active form text color
|
||||
form_active_text_color = button_key_active_color
|
||||
|
||||
# Form text color
|
||||
form_text_color = (WHITE,CYAN,ON)
|
||||
|
||||
# Readonly form item color
|
||||
form_item_readonly_color = (CYAN,WHITE,ON)
|
||||
|
||||
# Dialog box gauge color
|
||||
gauge_color = searchbox_title_color
|
||||
|
||||
# Dialog box border2 color
|
||||
border2_color = dialog_color
|
||||
|
||||
# Input box border2 color
|
||||
inputbox_border2_color = inputbox_color
|
||||
|
||||
# Search box border2 color
|
||||
searchbox_border2_color = inputbox_color
|
||||
|
||||
# Menu box border2 color
|
||||
menubox_border2_color = dialog_color
|
||||
@@ -84,6 +84,7 @@ BR2_PACKAGE_TCPDUMP=y
|
||||
BR2_PACKAGE_TRACEROUTE=y
|
||||
BR2_PACKAGE_ULOGD=y
|
||||
BR2_PACKAGE_BASH_COMPLETION=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
BR2_PACKAGE_NEOFETCH=y
|
||||
BR2_PACKAGE_PDMENU=y
|
||||
BR2_PACKAGE_TMUX=y
|
||||
|
||||
Reference in New Issue
Block a user