Root script at startup

Arch based Porteus community project

Moderator: M. Eerie

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Root script at startup

Post#1 by M. Eerie » 24 Jun 2019, 18:05

I've been trying to insert some routines to the startup sequence (...Ah-miga ) to patch the system depending on whether I am at home or at work.

To do certain tasks, I need elevated privileges, and this is where cliexec=myscript cheatcode, comes around. But every time I open a terminal, it tries to execute myscript :%)

For example @work where memory is limited, I'm removing the foreign locales:

Code: Select all

# REMOVE FOREIGN LOCALES
GLOBIGNORE=es:es_ES*:en:en_US*:locale.alias
cd /usr/share/locale
rm -r -- *
cd -
unset GLOBIGNORE

#PATCH DoubleCmd
if [[ $(lsblk -rno label | grep -E "APORTEUS|NEMESIS") ]] ; then
   sed -i 's/Bar1>True/Bar1>False/g' /home/guest/.config/doublecmd/doublecmd.xml
fi
...
This is fine, but then I need to mount a filesystem:

Code: Select all

[[ -f /mnt/sda1/tmp/myfiledisk ]] && mkdir -p /mnt/myfiledisk && mount /mnt/sda1/tmp/myfiledisk /mnt/myfiledisk
Obviously, it will fail, trying to mkdir @ /mnt.

Any help?

Thanks in advance. :)

Cheers!
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Root script at startup

Post#2 by ncmprhnsbl » 24 Jun 2019, 23:37

try putting your scripts in /etc/local.d and name them <myscriptname>.start (and be executable)
for example, i have a script that sets the power state for my graphics card, that i have in a module:

Code: Select all

ati-power/ati-pf
└── etc
    └── local.d
        └── atipowerstate.start
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Root script at startup

Post#3 by M. Eerie » 25 Jun 2019, 20:16

Yessssss !

That worked :beer:
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

Post Reply