Results 1 to 10 of 10

Thread: i want to run my own script at splash page time

  1. #1
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,858
    Distro
    Xubuntu 18.04 Bionic Beaver

    i want to run my own script at splash page time

    i want to run my own script at splash page time. this script does not open any windows and outputs nothing (to stdout or stderr) it does not access the display or the network. it does need to read files in /etc and /root and also needs to append a small amount of data to its own file(s) in those directories. it also needs to read /proc/partitions and on some occasions do a reboot (it can just run the reboot command if directly signalling init is not a good idea). does anyone know how to achieve this? is rebooting safe at that point of time?
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  2. #2
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,903
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: i want to run my own script at splash page time

    Quote Originally Posted by Skaperen View Post
    i want to run my own script at splash page time. this script does not open any windows and outputs nothing (to stdout or stderr) it does not access the display or the network. it does need to read files in /etc and /root and also needs to append a small amount of data to its own file(s) in those directories. it also needs to read /proc/partitions and on some occasions do a reboot (it can just run the reboot command if directly signalling init is not a good idea). does anyone know how to achieve this?
    Create a systemd service?

    As root or by using "sudo": Create a file with the name "/etc/systemd/system/nameofyourservice.service"
    Content could be:
    Code:
    [Unit]
    Description=NameOfYourService
    Requires=network.target
    After=systemd-user-sessions.service
    
    [Service]
    Type=simple
    ExecStart=/path/to/your/shell-script/that/does/the/stuff/you/want.sh
    # Please test your script first before you auto-hose your system at boot time!!
    User=root
    
    [Install]
    WantedBy=multi-user.target
    Once that file exists you can run these commands:
    Code:
    sudo systemctl daemon-reload
    sudo systemctl enable nameofyourservice
    If everything has been done correctly then your service should auto-run at the next reboot and do all the things you programmed it to do.

    Quote Originally Posted by Skaperen View Post
    is rebooting safe at that point of time?
    I don't think so. And I don't think it's even possible at that very moment because the system would still be in the process of booting up. But you could create a file that informs you of the need to reboot, so you could reboot manually once the system is up and running. It would not feel much different than after a normal system update.

    Your script could create this empty file, e.g with a simple "touch" command:
    Code:
    touch /var/run/reboot-required
    Once the file exists your system will constantly nag you that it needs to reboot.

  3. #3
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: i want to run my own script at splash page time

    Another experiment.
    If you install rEFIND to sit in /boot/efi/EFI/refind/
    you will find a ton of options in the refind.conf file
    including selecting your own splash theme and running scripts.

  4. #4
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,858
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: i want to run my own script at splash page time

    Quote Originally Posted by scorp123 View Post
    Once the file exists your system will constantly nag you that it needs to reboot.
    i want the reboot for this to be automatic and be done ASAP. this script is detecting a condition that is unsafe for the system to run. doing this before systemd even starts might be needed. making my own init in C (BTDT) that does the check and maybe reboots the kernel or execve()'s the systemd init is not off table.

    one aspect of the condition involves a possible USB hard drive left plugged in with the same UUID as the system root. left running this way, one or more hard drives could end up with tangled or lost files. i'd recognize the reboot and unplug the drive before BIOS runs, again. or maybe some kernel argument can detect this.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  5. #5
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,903
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: i want to run my own script at splash page time

    Quote Originally Posted by Skaperen View Post
    one aspect of the condition involves a possible USB hard drive left plugged in with the same UUID as the system root.
    Then change the UUID?

    Code:
    sudo tune2fs -U $(uuidgen) /dev/sdXwhatever
    Replace "/dev/sdX" with the actual value for the USB device.

  6. #6
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,858
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: i want to run my own script at splash page time

    changing the UUID is not an option for this setup. it is a sector backup. the UUID was just copied.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  7. #7
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,903
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: i want to run my own script at splash page time

    Quote Originally Posted by Skaperen View Post
    it is a sector backup.
    Why a sector backup? What for??

  8. #8
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,858
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: i want to run my own script at splash page time

    now we are getting off topic for this thread.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  9. #9
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,903
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: i want to run my own script at splash page time

    You expect solutions for self-inflicted problems. You could help yourself by not being so stubborn about doing these nonsensical things "your way" and be more open for suggestions by people who obviously know better.

  10. #10
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,858
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: i want to run my own script at splash page time

    if there were any "obviously know better" people around, i'd ask them my original question. hopefully they know not to tread off topic.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •