From a1be88d4bda48552426de3709176cbc7db9d7caa Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 2 Oct 2021 00:17:26 -0500 Subject: [PATCH] Update: Configuration settings changes. There will likely be several of these kinds of changes as I continue to implement functionality in controller and test it against my system. --- .../controller/data/settings/entries/default.entry | 13 +++-- .../settings/example/entries/environment.entry | 1 + .../data/settings/example/rules/delay/long.rule | 10 ++++ .../data/settings/example/rules/delay/short.rule | 10 ++++ .../example/rules/environment/exporting.rule | 22 +++++++ .../data/settings/rules/boot/devices.rule | 33 +++++++++++ .../data/settings/rules/boot/filesystem.rule | 11 +++- .../data/settings/rules/boot/modules.rule | 16 ++++-- .../controller/data/settings/rules/boot/proc.rule | 29 ++++++++++ .../controller/data/settings/rules/boot/root.rule | 67 ++++++++++++++++++++++ .../controller/data/settings/rules/net/all.rule | 1 + .../data/settings/rules/net/loopback.rule | 6 +- .../data/settings/rules/program/terminal.rule | 21 +++---- .../data/settings/rules/service/dbus.rule | 2 +- .../data/settings/rules/service/logger.rule | 2 +- .../data/settings/rules/service/mouse.rule | 20 +++++-- .../controller/data/settings/rules/task/clock.rule | 23 +++++--- .../data/settings/rules/task/keyboard.rule | 1 - .../data/settings/rules/task/ntpdate.rule | 28 +++++++++ 19 files changed, 272 insertions(+), 44 deletions(-) create mode 100644 level_3/controller/data/settings/example/rules/delay/long.rule create mode 100644 level_3/controller/data/settings/example/rules/delay/short.rule create mode 100644 level_3/controller/data/settings/example/rules/environment/exporting.rule create mode 100644 level_3/controller/data/settings/rules/boot/devices.rule create mode 100644 level_3/controller/data/settings/rules/boot/proc.rule create mode 100644 level_3/controller/data/settings/rules/boot/root.rule create mode 100644 level_3/controller/data/settings/rules/task/ntpdate.rule diff --git a/level_3/controller/data/settings/entries/default.entry b/level_3/controller/data/settings/entries/default.entry index ad102ec..f0e1189 100644 --- a/level_3/controller/data/settings/entries/default.entry +++ b/level_3/controller/data/settings/entries/default.entry @@ -17,10 +17,13 @@ main: item console boot: - start boot filesystem require - start boot modules require + start boot root require + start boot proc asynchronous require + start boot dev asynchronous require + start boot filesystem asynchronous + start boot modules wait - start service logger wait + start service logger start service dbus asynchronous ready @@ -35,8 +38,8 @@ keyboard: start task keyboard asynchronous console: + start service mouse asynchronous start program terminal require wait - start service mouse maintenance: - execute bash --login + execute /bin/bash --login diff --git a/level_3/controller/data/settings/example/entries/environment.entry b/level_3/controller/data/settings/example/entries/environment.entry index f09fea4..137031c 100644 --- a/level_3/controller/data/settings/example/entries/environment.entry +++ b/level_3/controller/data/settings/example/entries/environment.entry @@ -4,3 +4,4 @@ main: start environment default start environment exported start environment empty + start environment exporting diff --git a/level_3/controller/data/settings/example/rules/delay/long.rule b/level_3/controller/data/settings/example/rules/delay/long.rule new file mode 100644 index 0000000..e9557a6 --- /dev/null +++ b/level_3/controller/data/settings/example/rules/delay/long.rule @@ -0,0 +1,10 @@ +# fss-000d +# +# Rule for a long delay. +# + +setting: + name "Delay for 3 minutes." + +script: + start sleep 3m diff --git a/level_3/controller/data/settings/example/rules/delay/short.rule b/level_3/controller/data/settings/example/rules/delay/short.rule new file mode 100644 index 0000000..f014a22 --- /dev/null +++ b/level_3/controller/data/settings/example/rules/delay/short.rule @@ -0,0 +1,10 @@ +# fss-000d +# +# Rule for a short delay. +# + +setting: + name "Delay for 3 seconds." + +script: + start sleep 3s diff --git a/level_3/controller/data/settings/example/rules/environment/exporting.rule b/level_3/controller/data/settings/example/rules/environment/exporting.rule new file mode 100644 index 0000000..4353948 --- /dev/null +++ b/level_3/controller/data/settings/example/rules/environment/exporting.rule @@ -0,0 +1,22 @@ +# fss-000d + +setting: + name "Environment with PATH" + environment PATH custom_variable + script bash + +script: + start { + echo + echo "=================================" + echo "Exported Environment is isolated." + echo "=================================" + + export custom_variable="is not retained" + echo "export custom_variable='$custom_variable'" + echo + echo "Now for 'env' command:" + } + +command: + start env diff --git a/level_3/controller/data/settings/rules/boot/devices.rule b/level_3/controller/data/settings/rules/boot/devices.rule new file mode 100644 index 0000000..6dee78a --- /dev/null +++ b/level_3/controller/data/settings/rules/boot/devices.rule @@ -0,0 +1,33 @@ +# fss-000d +# +# Rule for initializing the /dev filesystem. +# + +setting: + name "Setup /dev filesystem" + + on start need boot root + +command: + start mount /dev + +script: + start { + if [[ ! -d /dev/pts ]] ; then + mkdir /dev/pts + fi + + if [[ ! -d /dev/shm ]] ; then + mkdir /dev/shm + fi + + exit 0 + } + +command: + start mount /dev/pts + stop umount -l /dev/pts + +command: + start mount /dev/shm + stop umount -l /dev/shm diff --git a/level_3/controller/data/settings/rules/boot/filesystem.rule b/level_3/controller/data/settings/rules/boot/filesystem.rule index 8618eb4..641686e 100644 --- a/level_3/controller/data/settings/rules/boot/filesystem.rule +++ b/level_3/controller/data/settings/rules/boot/filesystem.rule @@ -6,9 +6,16 @@ setting: name "Setup Filesystem" + on start need boot root + on start need boot proc + on start need boot devices + + on stop need boot proc + on stop need boot devices + command: - start mount -a -O no_netdev - stop umount -arf -O no_netdev + start mount -n -a -O no_netdev + stop umount -n -arf -O no_netdev command: start swapon -a diff --git a/level_3/controller/data/settings/rules/boot/modules.rule b/level_3/controller/data/settings/rules/boot/modules.rule index 58b8569..2852aef 100644 --- a/level_3/controller/data/settings/rules/boot/modules.rule +++ b/level_3/controller/data/settings/rules/boot/modules.rule @@ -6,17 +6,23 @@ setting: name "Setup Kernel Modules" - on start need boot filesystem + on start need boot root + on start need boot proc + on start want boot filesystem script: start { if [[ ! -f /proc/modules ]] ; then - exit 0; + exit 0 fi - if [[ ! -e /lib/modules/$(uname -r)/modules.dep ]] ; then - depmod; + if [[ -d /modules ]] ; then + if [[ ! -e /modules/$(uname -r)/modules.dep ]] ; then + depmod + else + depmod -A + fi fi - return 0; + exit 0 } diff --git a/level_3/controller/data/settings/rules/boot/proc.rule b/level_3/controller/data/settings/rules/boot/proc.rule new file mode 100644 index 0000000..12ffc18 --- /dev/null +++ b/level_3/controller/data/settings/rules/boot/proc.rule @@ -0,0 +1,29 @@ +# fss-000d +# +# Rule for initializing the /proc filesystem. +# + +setting: + name "Setup /proc Filesystem" + + on start need boot root + +command: + start mount /proc + +script: + start { + if [[ -d /proc/bus/usb ]] ; then + mount /proc/bus/usb + fi + + exit 0 + } + + stop { + if [[ -d /proc/bus/usb ]] ; then + umount -l /proc/bus/usb + fi + + exit 0 + } diff --git a/level_3/controller/data/settings/rules/boot/root.rule b/level_3/controller/data/settings/rules/boot/root.rule new file mode 100644 index 0000000..f5c63fe --- /dev/null +++ b/level_3/controller/data/settings/rules/boot/root.rule @@ -0,0 +1,67 @@ +# fss-000d +# +# Rule for initializing the root filesystem, assuring certain directories always exist. +# + +setting: + name "Setup Root Filesystem" + +command: + start mount -o remount,rw / + +script: + start { + if [[ ! -d /dev ]] ; then + mkdir /dev + fi + + if [[ ! -d /dev/pts ]] ; then + mkdir /dev/pts + fi + + if [[ ! -d /dev/shm ]] ; then + mkdir /dev/shm + fi + + if [[ ! -d /firmware ]] ; then + mkdir /firmware + fi + + if [[ ! -d /mnt ]] ; then + mkdir /mnt + fi + + if [[ ! -d /modules ]] ; then + mkdir /modules + fi + + if [[ ! -d /proc ]] ; then + mkdir /proc + fi + + if [[ ! -d /sys ]] ; then + mkdir /sys + fi + + if [[ ! -d /tmp ]] ; then + mkdir /tmp + fi + + if [[ ! -d /var ]] ; then + mkdir /var + fi + + if [[ ! -d /var/log ]] ; then + mkdir /var/log + fi + + if [[ ! -d /var/run ]] ; then + mkdir /var/run + fi + + if [[ ! -d /var/tmp ]] ; then + mkdir /var/tmp + fi + + exit 0 + } diff --git a/level_3/controller/data/settings/rules/net/all.rule b/level_3/controller/data/settings/rules/net/all.rule index 5d089cc..1d30602 100644 --- a/level_3/controller/data/settings/rules/net/all.rule +++ b/level_3/controller/data/settings/rules/net/all.rule @@ -5,6 +5,7 @@ setting: name "System Network" + capability cap_net_admin= command: start network start diff --git a/level_3/controller/data/settings/rules/net/loopback.rule b/level_3/controller/data/settings/rules/net/loopback.rule index aff02b4..957eb9c 100644 --- a/level_3/controller/data/settings/rules/net/loopback.rule +++ b/level_3/controller/data/settings/rules/net/loopback.rule @@ -10,10 +10,10 @@ setting: script: start { - ip addr add 127.0.0.1/8 label lo dev lo; - ip link set lo up; + ip addr add 127.0.0.1/8 label lo dev lo + ip link set lo up } stop { - ip link set lo down; + ip link set lo down } diff --git a/level_3/controller/data/settings/rules/program/terminal.rule b/level_3/controller/data/settings/rules/program/terminal.rule index 99dd544..81c7412 100644 --- a/level_3/controller/data/settings/rules/program/terminal.rule +++ b/level_3/controller/data/settings/rules/program/terminal.rule @@ -5,25 +5,20 @@ # -m = don't prompt for login. setting: - name "System Terminal" - capability "all=" + name "System Terminals" command: - #pid_file /var/run/tty/tty1.pid - - start agetty -8 9600 tty1 linux - -command: - #pid_file /var/run/tty/tty2.pid - start agetty -8 9600 tty2 linux command: - #pid_file /var/run/tty/tty3.pid - start agetty -8 9600 tty3 linux command: - #pid_file /var/run/tty/tty4.pid - start agetty -8 9600 tty4 linux + +# Wait for things to complete before opening the terminal on tty1. +command: + start sleep 3s + +command: + start agetty -8 9600 tty1 linux diff --git a/level_3/controller/data/settings/rules/service/dbus.rule b/level_3/controller/data/settings/rules/service/dbus.rule index d9cdb11..989b117 100644 --- a/level_3/controller/data/settings/rules/service/dbus.rule +++ b/level_3/controller/data/settings/rules/service/dbus.rule @@ -5,7 +5,7 @@ setting: name "D-BUS" - capability "all=" + capability all= nice 15 service: diff --git a/level_3/controller/data/settings/rules/service/logger.rule b/level_3/controller/data/settings/rules/service/logger.rule index 3d0f7cd..ad4eda2 100644 --- a/level_3/controller/data/settings/rules/service/logger.rule +++ b/level_3/controller/data/settings/rules/service/logger.rule @@ -5,7 +5,7 @@ setting: name "System Logger" - capability "all=" + capability all= nice 19 scheduler idle diff --git a/level_3/controller/data/settings/rules/service/mouse.rule b/level_3/controller/data/settings/rules/service/mouse.rule index 06a392c..0c41300 100644 --- a/level_3/controller/data/settings/rules/service/mouse.rule +++ b/level_3/controller/data/settings/rules/service/mouse.rule @@ -5,18 +5,28 @@ setting: name "Console Mouse" - capability "all=" + capability all= nice 15 - # @todo consider adding iki support. - script: start { - # @todo read settings from /etc/mouse, and replace below. + # This works if gpm service is run as root, but if not then this should be in a separate rule file with appropriate access to write to /var/run (don't forget to chown!). + if [[ ! -d /var/run/mouse/ && -d /var/run ]] ; then + mkdir /var/run/mouse/ + fi } service: pid_file /var/run/mouse/mouse.pid + # @todo consider a new type, such as "variable" than can be used to get the variable and store it in an iki parseable variable. + # This, however, may be too complicated than desirable (in terms of passing output back to the parent process). + # such as: + #variable device command fss_basic_read -can 0 device /etc/mouse + #variable protocal script { + # fss_basic_read -can 0 device /etc/mouse + #} + #variable options set "" + # @todo - start gpm -m [device] -t [protocol] [options] + start gpm -m variable:"device" -t variable:"protocol" variable:"options" diff --git a/level_3/controller/data/settings/rules/task/clock.rule b/level_3/controller/data/settings/rules/task/clock.rule index f0c789d..5e91914 100644 --- a/level_3/controller/data/settings/rules/task/clock.rule +++ b/level_3/controller/data/settings/rules/task/clock.rule @@ -5,27 +5,34 @@ setting: name "Setup Clock" - capability "all=" + capability cap_sys_time= nice 15 + on start want boot filesystem + on start want net all + script: start { + clock_file=/etc/clock clock_mode= + clock_server= + clock_ntpdate= - if [[ -f /etc/clock ]] ; then - clock_mode=$(fss_basic_read -c 0 -n mode /etc/clock); + if [[ -f $clock_file ]] ; then + clock_mode=$(fss_basic_read -can 0 mode $clock_file); + clock_server=$(fss_basic_read -can 0 server $clock_file) + clock_ntpdate=$(fss_basic_read -can 0 ntpdate $clock_file) fi if [[ $clock_mode == "local" ]] ; then hwclock --hctosys; - elif [[ $clock_mode == "ntpdate" ]] ; then - ntpdate $(fss_basic_read -c 0 -n server /etc/clock) && - hwclock --systohc --utc elif [[ $clock_mode == "ntp" ]] ; then - if [[ $(fss_basic_read -c 0 -n ntpdate /etc/clock) == "yes" ]] ; then - ntpdate $(fss_basic_read -c 0 -n server /etc/clock) && + if [[ $clock_ntpdate == "yes" ]] ; then + ntpdate $clock_server && hwclock --systohc --utc fi + elif [[ $clock_mode == "ntpdate" && $clock_host != "" ]] ; then + ntpdate $clock_server elif [[ $clock_mode == "utc" ]] ; then hwclock --hctosys --utc; fi diff --git a/level_3/controller/data/settings/rules/task/keyboard.rule b/level_3/controller/data/settings/rules/task/keyboard.rule index 07edc8a..ac3042e 100644 --- a/level_3/controller/data/settings/rules/task/keyboard.rule +++ b/level_3/controller/data/settings/rules/task/keyboard.rule @@ -5,5 +5,4 @@ setting: name "System Keyboard" - capability "all=" nice 15 diff --git a/level_3/controller/data/settings/rules/task/ntpdate.rule b/level_3/controller/data/settings/rules/task/ntpdate.rule new file mode 100644 index 0000000..2040744 --- /dev/null +++ b/level_3/controller/data/settings/rules/task/ntpdate.rule @@ -0,0 +1,28 @@ +# fss-000d +# +# Rule for executing ntpdate. +# + +setting: + name "System Clock Using NTP Date" + capability cap_sys_time= + nice 15 + + on start want boot filesystem + on start need net all + +script: + start { + clock_file=/etc/clock + clock_mode= + clock_server= + + if [[ -f $clock_file ]] ; then + clock_mode=$(fss_basic_read -can 0 mode $clock_file); + clock_server=$(fss_basic_read -can 0 server $clock_file) + fi + + if [[ $clock_mode == "ntpdate" && $clock_host != "" ]] ; then + ntpdate $clock_server + fi + } -- 1.8.3.1