Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shell script as a Session #852

Open
SajjadSabzkar opened this issue Sep 7, 2024 · 3 comments
Open

add shell script as a Session #852

SajjadSabzkar opened this issue Sep 7, 2024 · 3 comments

Comments

@SajjadSabzkar
Copy link

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
Copy link
Contributor

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
Copy link
Author

SajjadSabzkar commented Sep 11, 2024

thanks. but when this system service not started

image

@Thinstation
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants