Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
810 stars 188 forks source link

add shell script as a Session #852

Open sajjadsabzkar opened 2 months ago

sajjadsabzkar commented 2 months ago

Hi. I need to add a script for the lshw package and it will come up during boot and collect hardware information and put it inside the flash that has been burned. My first problem is how can I autostart my script as a session?

rohrbachger commented 1 month ago

I have done in this way. Look at a running system at /etc/init.d and /etc/systemd

Modify the lshw package or add a new for a net service

Create in /etc/init.d a service e.eg:

! /bin/sh

. dirname $0/common HOME=/etc/skel

case "$1" in init)

/bin/MyScript.sh

;; help) echo "Usage: $0 init" ;; *) exit 1 ;; esac

exit 0

Create a service definition under etc/systemd/system [Unit] Description=ThinStation MyDevices systemd unit After=profile-setup.service pkg.service ConditionPathIsReadWrite=/etc

[Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=/etc/thinstation.env ExecStart=/etc/init.d/MyDevices init SyslogIdentifier=thinstation

[Install] WantedBy=multi-user.target

sajjadsabzkar commented 1 month ago

thanks. but when this system service not started

image

Thinstation commented 1 month ago

You will need to add a link in multi-user.target.wants that points to the service file you created.