Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-mount boot (and several recipe cleanups) #245

Merged
merged 11 commits into from
Feb 4, 2022
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable dropbear.socket
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ Before=rescue.service
# unit.
ConditionPathExists=/dev/tty0

# This service can be used to manipulate settings in /boot/config.uEnv
Wants=boot.automount
After=boot.automount

[Service]
ExecStart=/opt/bin/ovmenu-ng.sh
ExecStart=/usr/bin/ovmenu-ng.sh
Type=idle
Restart=always
RestartSec=0
Expand Down
56 changes: 46 additions & 10 deletions meta-ov/recipes-apps/ovmenu-ng/files/ovmenu-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
TIMEOUT=3
INPUT=/tmp/menu.sh.$$

TOUCH_CAL=/opt/conf/touch.cal

# trap and delete temp files
trap "rm $INPUT;rm /tmp/tail.$$; exit" SIGHUP SIGINT SIGTERM

Expand Down Expand Up @@ -137,6 +135,7 @@ function submenu_settings() {
Display_Rotation "Set rotation of the display" \
LCD_Brightness "Set display brightness" \
XCSoar_Language "Set language used for XCSoar" \
SSH "Enable or disable SSH" \
Back "Back to Main" 2>"${INPUT}"

menuitem=$(<"${INPUT}")
Expand All @@ -152,6 +151,9 @@ function submenu_settings() {
XCSoar_Language)
submenu_xcsoar_lang
;;
SSH)
submenu_ssh
;;
Back) ;;
esac
}
Expand Down Expand Up @@ -190,6 +192,38 @@ function submenu_xcsoar_lang() {
export LANG="$menuitem"
}

function submenu_ssh() {
if /bin/systemctl --quiet is-enabled dropbear.socket; then
local state=enabled
elif /bin/systemctl --quiet is-active dropbear.socket; then
local state=temporary
else
local state=disabled
fi

dialog --nocancel --backtitle "OpenVario" \
--title "[ S S H ]" \
--begin 3 4 \
--default-item "${state}" \
--menu "SSH access is currently ${state}." 15 50 4 \
enabled "Enable SSH permanently" \
temporary "Enable SSH temporarily (until reboot)" \
disabled "Disable SSH" \
2>"${INPUT}"
menuitem=$(<"${INPUT}")

if test "${state}" != "$menuitem"; then
if test "$menuitem" = "enabled"; then
/bin/systemctl enable --now dropbear.socket
elif test "$menuitem" = "temporary"; then
/bin/systemctl disable dropbear.socket
/bin/systemctl start dropbear.socket
else
/bin/systemctl disable --now dropbear.socket
fi
fi
}

function submenu_lcd_brightness() {
while [ $? -eq 0 ]
do
Expand Down Expand Up @@ -217,8 +251,6 @@ done
}

function submenu_rotation() {

mount /dev/mmcblk0p1 /boot
TEMP=$(grep "rotation" /boot/config.uEnv)
if [ -n $TEMP ]; then
ROTATION=${TEMP: -1}
Expand All @@ -236,14 +268,13 @@ function submenu_rotation() {
# update config
# uboot rotation
sed -i 's/^rotation=.*/rotation='$menuitem'/' /boot/config.uEnv
dialog --msgbox "New Setting saved !!\n Touch recalibration required !!\n A Reboot is required !!!" 10 50
echo "$menuitem" >/sys/class/graphics/fbcon/rotate
dialog --msgbox "New Setting saved !!\n Touch recalibration required !!" 10 50
else
dialog --backtitle "OpenVario" \
--title "ERROR" \
--msgbox "No Config found !!"
fi

umount /boot
}

function update_system() {
Expand Down Expand Up @@ -353,12 +384,17 @@ function yesno_exit(){
0)
clear
cd

# Redirecting stderr to stdout (= the console)
# because stderr is currently connected to
# systemd-journald, which breaks interactive
# shells.
if test -x /bin/bash; then
/bin/bash --login
/bin/bash --login 2>&1
elif test -x /bin/ash; then
/bin/ash -i
/bin/ash -i 2>&1
else
/bin/sh
/bin/sh 2>&1
fi
;;
esac
Expand Down
32 changes: 25 additions & 7 deletions meta-ov/recipes-apps/ovmenu-ng/ovmenu-ng_0.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,54 @@ SECTION = "base/app"
S = "${WORKDIR}"
PR = "r15"

inherit allarch
inherit allarch systemd

RDEPENDS:${PN} = " \
bash \
dialog \
ovmenu-ng-skripts \
ov-tools \
autofs-config \
"

# the "autologin" package is obsolete and interferes with this one
# the "autostart" package was merged into this one
RCONFLICTS:${PN} = " \
openvario-autologin \
ovmenu-ng-autostart \
"

SRC_URI = "\
file://ovmenu-ng.sh \
file://openvario.rc \
file://${PN}.service \
file://disable_dropbear.preset \
"


addtask do_package_write_ipk after do_package

do_compile() {
:
:
}

do_install() {
echo "Installing ..."
install -d ${D}/opt/bin ${D}/opt/conf
install -m 0755 ${S}/ovmenu-ng.sh ${D}/opt/bin/ovmenu-ng.sh
install -d ${D}/${bindir}
install -m 0755 ${S}/ovmenu-ng.sh ${D}/${bindir}
install -d ${D}${ROOT_HOME}
install -m 0755 ${S}/openvario.rc ${D}${ROOT_HOME}/.dialogrc
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/ovmenu-ng.service ${D}${systemd_unitdir}/system

# TODO: move this preset file to a more appropriate recipe
install -d ${D}${systemd_unitdir}/system-preset
install -m 0644 ${WORKDIR}/disable_dropbear.preset ${D}${systemd_unitdir}/system-preset/50-disable_dropbear.preset
}

FILES:${PN} = "/opt/bin/ovmenu-ng.sh \
/opt/conf \
SYSTEMD_SERVICE:${PN} = "${PN}.service"

FILES:${PN} = " \
${bindir}/ovmenu-ng.sh \
${ROOT_HOME}/.dialogrc \
${systemd_unitdir}/system-preset/50-disable_dropbear.preset \
"
1 change: 0 additions & 1 deletion meta-ov/recipes-core/images/openvario-base-image.bb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ LOCALE_PACKAGES = " \
IMAGE_INSTALL = " \
packagegroup-base \
distro-feed-configs \
autofs-config \
nano \
openssh-sftp-server \
tslib \
Expand Down
2 changes: 1 addition & 1 deletion meta-ov/recipes-core/images/openvario-image-testing.bb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IMAGE_INSTALL += "\
xcsoar-maps-default \
sensord-testing\
variod-testing \
ovmenu-ng-autostart \
ovmenu-ng \
"

export IMAGE_BASENAME = "openvario-image-testing"
2 changes: 1 addition & 1 deletion meta-ov/recipes-core/images/openvario-image.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ IMAGE_INSTALL += "\
caltool \
sensord \
variod \
ovmenu-ng-autostart \
ovmenu-ng \
"

export IMAGE_BASENAME = "openvario-image"
19 changes: 5 additions & 14 deletions meta-ov/recipes-core/psplash/files/psplash-rotation
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
#!/bin/sh

# reads rotation from cmdline convert it to degrees and writes
# convert fbcon/rotate to degrees

read -r cmdline < /proc/cmdline
for param in ${cmdline} ; do
case "${param}" in
fbcon=*)
fbcon="${param#fbcon=}"
;;
esac
done

case "${fbcon}" in
"rotate:3")
case "$(cat /sys/class/graphics/fbcon/rotate)" in
"3")
rotation=90
;;
"rotate:2")
"2")
rotation=180
;;
"rotate:1")
"1")
rotation=270
;;
*)
Expand Down
16 changes: 14 additions & 2 deletions meta-ov/recipes-support/autofs-config/autofs-config_0.2.bb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ PR = "r1"
inherit allarch systemd

SRC_URI = "\
file://boot.mount \
file://boot.automount \
file://usb-usbstick.mount \
file://usb-usbstick.automount \
"

SYSTEMD_SERVICE:${PN} = "usb-usbstick.mount usb-usbstick.automount"
SYSTEMD_SERVICE:${PN} = " \
boot.mount \
boot.automount \
usb-usbstick.mount \
usb-usbstick.automount \
"

do_configure() {
:
Expand All @@ -22,5 +29,10 @@ do_compile() {

do_install() {
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/usb-usbstick.mount ${WORKDIR}/usb-usbstick.automount ${D}${systemd_unitdir}/system
install -m 0644 \
${WORKDIR}/boot.mount \
${WORKDIR}/boot.automount \
${WORKDIR}/usb-usbstick.mount \
${WORKDIR}/usb-usbstick.automount \
${D}${systemd_unitdir}/system
}
5 changes: 5 additions & 0 deletions meta-ov/recipes-support/autofs-config/files/boot.automount
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=Automatically mount the boot partition

[Automount]
Where=/boot
8 changes: 8 additions & 0 deletions meta-ov/recipes-support/autofs-config/files/boot.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Mount the boot partition

[Mount]
What=/dev/mmcblk0p1
Where=/boot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would /etc/fstab entry be a simpler solution for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we can change this afterwards as well, but it doesn't matter from my point of view ..

Type=vfat
Options=nodev,noexec,nosuid,noatime,rw,sync

This file was deleted.