Skip to content
Snippets Groups Projects
Verified Commit 52b5e216 authored by Qiyang Sun's avatar Qiyang Sun :speech_balloon:
Browse files

Add script to change runlevel

parent 75d79944
Branches
No related tags found
No related merge requests found
.TH CHLEVEL 1 "November 2024" "Version 0.1" "General Commands Manual"
.SH NAME
chlevel.sh \- change fastinit runlevel
.SH SYNOPSIS
.B /usr/sbin/chlevel.sh
\fIrunlevel\fP
.SH DESCRIPTION
Chlevel.sh remounts the boot filesystem, edit the kernel command line to change the runlevel and restart the system.
.SH SEE ALSO
.BR runlevel (8),
.BR fastinit (8),
.BR mount (8)
.SH AUTHOR
The
.B chlevel
script was first written by Qiyang Sun <qs2g22@soton.ac.uk>, and is maintained by the MAR24 project maintainers.
#!/bin/sh
runlevel=$1
case $runlevel in
1)
mount -o rw,remount /boot
cat > /boot/cmdline.txt <<EOF
quiet loglevel=0 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait logo.nologo net.ifnames=0 modules.load=dwc2,g_serial init=/usr/sbin/fastinit.sh 1
EOF
reboot -f
;;
2)
mount -o rw,remount /boot
cat > /boot/cmdline.txt <<EOF
quiet loglevel=0 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait logo.nologo net.ifnames=0 modules.load=dwc2,g_serial init=/usr/sbin/fastinit.sh 2
EOF
reboot -f
;;
3)
mount -o rw,remount /boot
cat > /boot/cmdline.txt <<EOF
dwc_otg.lpm_enable=0 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait logo.nologo net.ifnames=0 modules.load=dwc2,g_serial earlycon=uart8250,mmio32,0x20215040 init=/usr/sbin/fastinit.sh 3
EOF
reboot -f
;;
5)
mount -o rw,remount /boot
cat > /boot/cmdline.txt <<EOF
dwc_otg.lpm_enable=0 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait logo.nologo net.ifnames=0 modules.load=dwc2,g_serial earlycon=uart8250,mmio32,0x20215040 init=/usr/sbin/fastinit.sh 5
EOF
reboot -f
;;
*)
echo "Invalid new runlevel"
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment