How do I put a .sh on startup? [help]

Post here if you are a new Porteus member and you're looking for some help.
mcabel
White ninja
White ninja
Posts: 19
Joined: 09 Aug 2018, 23:56
Distribution: mgame

How do I put a .sh on startup? [help]

Post#1 by mcabel » 05 Dec 2022, 20:13

How do I put this .sh on startup?

Redshift3000.sh

Code: Select all

#!/bin/bash 
redshift -P -O 3000

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#2 by Ed_P » 05 Dec 2022, 21:45

Add the .sh file to /etc/profile.d as root.
Ed

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

How do I put a .sh on startup? [help]

Post#3 by ncmprhnsbl » 06 Dec 2022, 01:03

Ed_P wrote:
05 Dec 2022, 21:45
Add the .sh file to /etc/profile.d as root.
generally, this location is for setting environment variables, not random commands..
putting that command in /etc/rc.d/rc.local is more conventional
or
creating a .desktop file and putting it in ~/.config/autostart (or /etc/xdg/autostart) like this:
redshift.desktop:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=redshift
Exec=redshift -P -O 3000

or in that .desktop:
Exec=/path/to/the/script.sh
or
add to the APPEND line of /boot/syslinux/porteus.cfg : guiexec=reshift~-P~-O~3000 (~ replaces spaces) or guiexec=/path/to/the/script.sh
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

gnintilgyes
Black ninja
Black ninja
Posts: 73
Joined: 14 Sep 2022, 17:52
Distribution: Debian

How do I put a .sh on startup? [help]

Post#4 by gnintilgyes » 06 Dec 2022, 02:37

ncmprhnsbl wrote:
06 Dec 2022, 01:03
generally, this location is for setting environment variables, not random commands..
putting that command in /etc/rc.d/rc.local is more conventional
or
creating a .desktop file and putting it in ~/.config/autostart (or /etc/xdg/autostart) like this:
redshift.desktop:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=redshift
Exec=redshift -P -O 3000

I learned something else about Linux. Even though once I had to tread around "/etc/rc.d" looking how to turn "init 3" into "init 4" after I installed Slackware 32-bit and created a regular user. :)

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#5 by Ed_P » 06 Dec 2022, 06:45

ncmprhnsbl wrote:
06 Dec 2022, 01:03
Ed_P wrote:
05 Dec 2022, 21:45
Add the .sh file to /etc/profile.d as root.
generally, this location is for setting environment variables, not random commands..
putting that command in /etc/rc.d/rc.local is more conventional
or
creating a .desktop file and putting it in ~/.config/autostart (or /etc/xdg/autostart) like this:
redshift.desktop:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=redshift
Exec=redshift -P -O 3000
or in that .desktop:
Exec=/path/to/the/script.sh
or
add to the APPEND line of /boot/syslinux/porteus.cfg : guiexec=reshift~-P~-O~3000 (~ replaces spaces) or guiexec=/path/to/the/script.sh
An excellent posting ncmp. :good: We need to find a way to add it to the forum's help file.
Ed

roro
Black ninja
Black ninja
Posts: 65
Joined: 04 Aug 2022, 08:41
Distribution: Porteus 5.0 XFCE

How do I put a .sh on startup? [help]

Post#6 by roro » 06 Dec 2022, 16:58

Hi ncmp... and ED_P
Now I've learned two things at once
"desktop file" and "autostart"
That means I have to check the forum every day.

But where do I have to save the desktop file

/home/guest/.config/autostart
or /etc/xdg/autostart

Both: autostart, what is the difference, what is xdg ?

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

How do I put a .sh on startup? [help]

Post#7 by ncmprhnsbl » 07 Dec 2022, 01:12

roro wrote:
06 Dec 2022, 16:58
Both: autostart, what is the difference, what is xdg
/home/guest/.config/autostart starts for guest user only, /etc/xdg/autostart starts for all users (when they login to X)
xdg is an acronym for "X (or cross) desktop group" , which is a freedesktop.org creation that handles/standardizes various functions across desktop environments, like for example: autostart, config file locations, standard desktop folders...
(don't worry, i had to look that up ;) )
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

Kulle
Warlord
Warlord
Posts: 591
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

How do I put a .sh on startup? [help]

Post#8 by Kulle » 26 Mar 2023, 10:36

"Script.sh" file at startup

Two possibilities:

a) creating a .desktop file "Script.sh" and putting it in ~/.config/autostart
or
b) Cheatcode: guiexec=/usr/bin/Script.sh

What is better? What is recommended?

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#9 by Ed_P » 26 Mar 2023, 14:29

Kulle wrote:
26 Mar 2023, 10:36
What is better?
b) Cheatcode: guiexec=/home/guest/startup.sh

Easier to maintain, as in use or comment out or change to a different file.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

How do I put a .sh on startup? [help]

Post#10 by Rava » 28 Mar 2023, 23:46

Ed_P wrote:
26 Mar 2023, 14:29
b) Cheatcode: guiexec=/home/guest/startup.sh

Easier to maintain, as in use or comment out or change to a different file.
when you use a rootcopy/ folder then putting the script into rootcopy/home/guest/.config/autostart is as easy to change.
When you not have a rootcopy/ folder, then Ed_P is correct.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#11 by Ed_P » 29 Mar 2023, 05:39

Will my approach work with the rootcopy function? Does your approach allow the name of the script to be changed before booting Porteus?
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

How do I put a .sh on startup? [help]

Post#12 by Rava » 29 Mar 2023, 06:22

No and No.


But does your approach allow the changing (as in: creating, editing) of the script prior booting Porteus? No it also does not.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#13 by Ed_P » 29 Mar 2023, 12:51

Rava wrote:
29 Mar 2023, 06:22
But does your approach allow the changing (as in: creating, editing) of the script prior booting Porteus?
Yes it does. I boot my ISO and update my scripts on my USB drive before rebooting the drive. ;)
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

How do I put a .sh on startup? [help]

Post#14 by Rava » 29 Mar 2023, 16:02

Ed_P wrote:
29 Mar 2023, 12:51
Rava wrote:
29 Mar 2023, 06:22
But does your approach allow the changing (as in: creating, editing) of the script prior booting Porteus?
Yes it does. I boot my ISO and update my scripts on my USB drive before rebooting the drive. ;)
I wrote: Can you update your script prior booting Port.

Booting Port via ISO is still booting Port. So the correct answer is: no, you cannot change the script without booting Port.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8315
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

How do I put a .sh on startup? [help]

Post#15 by Ed_P » 29 Mar 2023, 20:33

Rava wrote:
29 Mar 2023, 16:02
Booting Port via ISO is still booting Port. So the correct answer is: no, you cannot change the script without booting Port.
Ok but actually I can update it without booting Port or the ISO. I plug the USB stick into my Windows system and add/delete/rename the script that way. NO booting needed. :D
Ed

Post Reply