Run readonly.sh with sudo, remove all sudo from readonly.sh

This commit is contained in:
starcalc 2022-03-09 10:39:48 +01:00
parent 27e13d5fe5
commit 3ae31ab6fe
2 changed files with 23 additions and 23 deletions

View File

@ -27,7 +27,7 @@ After login (ssh) proceed with these steps:
12. `sudo chmod u+x /etc/rc.local` 12. `sudo chmod u+x /etc/rc.local`
13. `chmod u+x ~/bananenkeyboard/piconfig/readonly.sh` 13. `chmod u+x ~/bananenkeyboard/piconfig/readonly.sh`
14. `sudo gpasswd --add pi tty` 14. `sudo gpasswd --add pi tty`
15. `~/bananenkeyboard/piconfig/readonly.sh` 15. `sudo /home/pi/bananenkeyboard/piconfig/readonly.sh`
16. `sudo reboot` 16. `sudo reboot`
By copying the rc.local (step 11), the script will be started in a `screen` after reboot. By copying the rc.local (step 11), the script will be started in a `screen` after reboot.

View File

@ -1,28 +1,28 @@
sudo apt remove -y --purge triggerhappy logrotate dphys-swapfile cron apt remove -y --purge triggerhappy logrotate dphys-swapfile cron
sudo apt autoremove -y --purge apt autoremove -y --purge
sudo apt install -y busybox-syslogd apt install -y busybox-syslogd
sudo apt remove -y --purge rsyslog apt remove -y --purge rsyslog
sudo sh -c 'echo -n "fastboot noswap ro" >>/boot/cmdline.txt' sh -c 'echo -n "fastboot noswap ro" >>/boot/cmdline.txt'
sudo rm -rf /var/lib/dhcp/ /var/run /var/spool /var/lock /etc/resolv.conf rm -rf /var/lib/dhcp/ /var/run /var/spool /var/lock /etc/resolv.conf
sudo ln -s /tmp /var/lib/dhcp ln -s /tmp /var/lib/dhcp
sudo ln -s /tmp /var/run ln -s /tmp /var/run
sudo ln -s /tmp /var/spool ln -s /tmp /var/spool
sudo ln -s /tmp /var/lock ln -s /tmp /var/lock
sudo touch /tmp/dhcpcd.resolv.conf; ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf touch /tmp/dhcpcd.resolv.conf; ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf
sudo rm /var/lib/systemd/random-seed rm /var/lib/systemd/random-seed
sudo ln -s /tmp/random-seed /var/lib/systemd/random-seed ln -s /tmp/random-seed /var/lib/systemd/random-seed
sudo sed -i 's#ExecStart=/lib/systemd/systemd-random-seed load#ExecStartPre=/bin/echo "" >/tmp/random-seed\nExecStart=/lib/systemd/systemd-random-seed load#' /lib/systemd/system/systemd-random-seed.service sed -i 's#ExecStart=/lib/systemd/systemd-random-seed load#ExecStartPre=/bin/echo "" >/tmp/random-seed\nExecStart=/lib/systemd/systemd-random-seed load#' /lib/systemd/system/systemd-random-seed.service
sudo systemctl daemon-reload systemctl daemon-reload
sudo systemctl disable console-setup systemctl disable console-setup
sudo sed -i 's#\(.*PARTUUID.*defaults\)\(.*\)#\1,ro\2#' /etc/fstab sed -i 's#\(.*PARTUUID.*defaults\)\(.*\)#\1,ro\2#' /etc/fstab
sudo cat <<EOT >>/etc/fstab cat <<EOT >>/etc/fstab
tmpfs /tmp tmpfs nosuid,nodev 0 0 tmpfs /tmp tmpfs nosuid,nodev 0 0
tmpfs /var/log tmpfs nosuid,nodev 0 0 tmpfs /var/log tmpfs nosuid,nodev 0 0
tmpfs /var/tmp tmpfs nosuid,nodev 0 0 tmpfs /var/tmp tmpfs nosuid,nodev 0 0
EOT EOT
sudo cat <<"EOT" >>/etc/bash.bashrc cat <<"EOT" >>/etc/bash.bashrc
# set variable identifying the filesystem you work in (used in the prompt below) # set variable identifying the filesystem you work in (used in the prompt below)
set_bash_prompt(){ set_bash_prompt(){
fs_mode=$(mount | sed -n -e "s/^\/dev\/.* on \/ .*(\(r[w|o]\).*/\1/p") fs_mode=$(mount | sed -n -e "s/^\/dev\/.* on \/ .*(\(r[w|o]\).*/\1/p")
@ -32,11 +32,11 @@ set_bash_prompt(){
alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot' alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot'
alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot' alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot'
# setup fancy prompt" # setup fancy prompt
PROMPT_COMMAND=set_bash_prompt PROMPT_COMMAND=set_bash_prompt
EOT EOT
sudo cat <<EOT >>/etc/bash.bash_logout cat <<EOT >>/etc/bash.bash_logout
sudo mount -o remount,rw / sudo mount -o remount,rw /
history -a history -a
sudo mount -o remount,ro / sudo mount -o remount,ro /