Ravas coding goodies

For discussions about programming and projects not necessarily associated with Porteus.
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

Ravas coding goodies

Post#106 by Rava » 09 Feb 2022, 19:29

Ed_P wrote:
09 Feb 2022, 16:53
Actually I editted the script to include:

Code: Select all

export DRV
exit
before the echos and added the line:

Code: Select all

/home/guest/DRV.sh
to the /etc/rc.d/rc.local/ file and rebooted but echo $DRV is empty. :(
What script does the initialization of $DRV ?
/home/guest/DRV.sh or /etc/rc.d/rc.local (It is not /etc/rc.d/rc.local/ !)

I think when it's a variable previously unknown to the system you have to do it in /etc/rc.d/ - preferable using /etc/rc.d/rc.local
Just look into how the maintainers manage to get e.g. $PORTDIR to work - where it is initialized, and how it gets exported and where that exporting is coded…
Ed_P wrote:
09 Feb 2022, 16:53
There's some other approaches I will try. :)
Tell us when it succeeded.
Cheers!
Yours Rava

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

Ravas coding goodies

Post#107 by Ed_P » 10 Feb 2022, 07:55

Rava wrote:
09 Feb 2022, 19:29
Just look into how the maintainers manage to get e.g. $PORTDIR to work - where it is initialized, and how it gets exported and where that exporting is coded…
:%) Where did they do it?
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

Ravas coding goodies

Post#108 by Rava » 10 Feb 2022, 10:54

Ed_P wrote:
10 Feb 2022, 07:55
:%) Where did they do it?
No clue, do a search for it in /etc/ text files. Start with /etc/rc.d/
Cheers!
Yours Rava

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

Ravas coding goodies

Post#109 by Ed_P » 10 Feb 2022, 16:57

Finding where they set BOOTDEV might be interesting also. :)

Added in 4 hours 24 minutes 14 seconds:
Not doing well so far.

Code: Select all

guest@porteus:/etc/rc.d$ find . -maxdepth 2 -type f -exec grep "PORTDIR" "{}" \;
grep: ./rc.inet1.conf: Permission denied
grep: ./rc.wireless.conf: Permission denied
guest@porteus:/etc/rc.d$ find . -maxdepth 2 -type f -exec grep "BOOTDEV" "{}" \;
grep: ./rc.inet1.conf: Permission denied
grep: ./rc.wireless.conf: Permission denied
guest@porteus:/etc/rc.d$ 
Added in 28 minutes 41 seconds:
Making progress, I think.

Code: Select all

guest@porteus:/etc/rc.d$ cd ..
guest@porteus:/etc$ find . -maxdepth 3 -type f -exec grep "BOOTDEV" "{}" \;
grep: ./NetworkManager/system-connections/Auto ATWELL WILD COTTAGE: Permission denie
grep: ./NetworkManager/system-connections/Auto RRH_guest: Permission denied
grep: ./NetworkManager/system-connections/Auto TP-LINK_Smart Plug_88B6: Permission denied
grep: ./NetworkManager/system-connections/Auto hobbolly: Permission denied
grep: ./NetworkManager/system-connections/gogoinflight: Permission denied
find: ‘./cups/ssl’: Permission denied
grep: ./cups/printers.conf: Permission denied
grep: ./random-seed: Permission denied
export BOOTDEV=/mnt/isoloop
grep: ./rc.d/rc.inet1.conf: Permission denied
grep: ./rc.d/rc.wireless.conf: Permission denied
grep: ./lxdm/lxdm.conf: Permission denied
grep: ./ppp/chap-secrets: Permission denied
grep: ./ppp/pap-secrets: Permission denied
grep: ./radiusclient/realms: Permission denied
grep: ./radiusclient/servers: Permission denied
grep: ./sudoers: Permission denied
grep: ./sudoers.dist: Permission denied
grep: ./wpa_supplicant.conf: Permission denied
guest@porteus:/etc$ find . -maxdepth 3 -type f -exec grep "PORTDIR" "{}" \;
grep: ./NetworkManager/system-connections/Auto ATWELL WILD COTTAGE: Permission denied
grep: ./NetworkManager/system-connections/Auto RRH_guest: Permission denied
grep: ./NetworkManager/system-connections/Auto TP-LINK_Smart Plug_88B6: Permission denied
grep: ./NetworkManager/system-connections/Auto hobbolly: Permission denied
grep: ./NetworkManager/system-connections/gogoinflight: Permission denied
find: ‘./cups/ssl’: Permission denied
grep: ./cups/printers.conf: Permission denied
grep: ./random-seed: Permission denied
export PORTDIR=/mnt/isoloop/porteus
grep: ./rc.d/rc.inet1.conf: Permission denied
grep: ./rc.d/rc.wireless.conf: Permission denied
grep: ./lxdm/lxdm.conf: Permission denied
grep: ./ppp/chap-secrets: Permission denied
grep: ./ppp/pap-secrets: Permission denied
grep: ./radiusclient/realms: Permission denied
grep: ./radiusclient/servers: Permission denied
grep: ./sudoers: Permission denied
grep: ./sudoers.dist: Permission denied
grep: ./wpa_supplicant.conf: Permission denied
guest@porteus:/etc$ 
Ed

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

Ravas coding goodies

Post#110 by ncmprhnsbl » 10 Feb 2022, 21:59

/etc/profile.d/porteus.sh
this file is created by initrd(linuxrc) at boot time
but, yeah, to set an env variable, add a file to /etc/profile.d:
my_env_var.sh

Code: Select all

export MYVAR=some_variable
make sure it's executable (chmod +x)

and btw, when you get "permission denied" messages like that, try it as root ;)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

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

Ravas coding goodies

Post#111 by Ed_P » 11 Feb 2022, 01:28

ncmprhnsbl wrote:
10 Feb 2022, 21:59
but, yeah, to set an env variable, add a file to /etc/profile.d:
my_env_var.sh
Thank you ncmp. :celebrate14:
ncmprhnsbl wrote:
10 Feb 2022, 21:59
make sure it's executable (chmod +x)
Understood. :happy62:
ncmprhnsbl wrote:
10 Feb 2022, 21:59
and btw, when you get "permission denied" messages like that, try it as root
Yes, I know. :) I wasn't done with my "find"ing. ;)

Added in 4 hours 5 minutes 10 seconds:
It works ncmp. :good: Thank you. :beer:

Code: Select all

guest@porteus:~$ echo $BOOTDEV
/mnt/isoloop
guest@porteus:~$ echo $DRV
nvme0n1p7
guest@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

Ravas coding goodies

Post#112 by Rava » 11 Feb 2022, 07:21

Ed_P wrote:
10 Feb 2022, 21:50
Not doing well so far.

Code: Select all

guest@porteus:/etc/rc.d$ find . -maxdepth 2 -type f -exec grep "PORTDIR" "{}" \;
grep: ./rc.inet1.conf: Permission denied
grep: ./rc.wireless.conf: Permission denied
guest@porteus:/etc/rc.d$ find . -maxdepth 2 -type f -exec grep "BOOTDEV" "{}" \;
grep: ./rc.inet1.conf: Permission denied
grep: ./rc.wireless.conf: Permission denied
guest@porteus:/etc/rc.d$ 
These are system settings, and at boot time most is done by root…

Try the same searches as root. :)

Oh wait, … what a bummer, ncmprhnsbl beat me to it.
ncmprhnsbl wrote:
10 Feb 2022, 21:59
and btw, when you get "permission denied" messages like that, try it as root ;)
Could not have said it better.

Thanks ncmprhnsbl. Image
Cheers!
Yours Rava

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

Ravas coding goodies

Post#113 by Ed_P » 11 Feb 2022, 16:33

Rava wrote:
11 Feb 2022, 07:21
Try the same searches as root.

Code: Select all

root@porteus:/etc#  find . -maxdepth 3 -type f -exec grep "BOOTDEV" "{}" \;
export BOOTDEV=/mnt/isoloop
Defaults env_keep += "PORTDIR BOOTDEV"
root@porteus:/etc# 
The bigger problem with my "find" is it didn't show the name of the file the "find" was found in. :unknown:
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

Ravas coding goodies

Post#114 by Rava » 11 Feb 2022, 17:43

^
indeed, but I am too worn out (mentally and physically) to think of the solution out of the box.

Maybe searching the usual suspects - you know, sites like https://www.geeksforgeeks.org or https://stackoverflow.com/ (try searching on that site, probably a similar question got already asked, but they want you do show some effort already, they are IT professionals and think of you as one as well, not a slacker who thinks folks on the net solves his/her homework assignment) or such:
https://linuxconfig.org/bash-scripting- ... -beginners
https://guide.bash.academy/
https://medium.com/javarevisited/6-free ... 0461ecd4fe

And last but not least a must read:
https://tldp.org/LDP/Bash-Beginners-Gui ... -Guide.pdf
Also, almost everything on https://tldp.org - it has also a wiki:
The Linux Documentation Project Wiki Image

HTH!
Cheers!
Yours Rava

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

Ravas coding goodies

Post#115 by Rava » 11 Feb 2022, 19:55

*steps in, looks around*
Rava: "Good, no one here, let me drop this self quote real quick"

*drops*
Rava wrote:
11 Feb 2022, 19:52
My created by my make-ffplay-script V3.48 Enya.sh script in action:
Image
https://abload.de/img/screenshot_2022-02-11okjwp.png

(and later on "Sail away, sail away, sail away…" (from "Orinoco Flow")) Image
Rava *runs off*

P.S. System Porteus 5.0rc3 XFCE 4.12. Image
xfce-terminal Settings: Font DejaVu Sans Mono Book 16pt
Font size quite large because it's a FullHD display.
Cheers!
Yours Rava

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

Ravas coding goodies

Post#116 by Ed_P » 11 Feb 2022, 20:05

Rava wrote:
11 Feb 2022, 19:54
I am too worn out (mentally and physically) to think of the solution out of the box.
That's ok, I know how to use Google. I just thought you were the "find" king based on some of your postings and knew "find" intimately. :D
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

Ravas coding goodies

Post#117 by Rava » 11 Feb 2022, 20:08

Ed_P wrote:
11 Feb 2022, 20:05
That's ok, I know how to use Google. I just thought you were the "find" king based on some of your postings and knew "find" intimately.
I only know some small things compared to what find can do for you. :D
Cheers!
Yours Rava

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

Ravas coding goodies

Post#118 by Ed_P » 11 Feb 2022, 21:03

For those that may stumble upon this in the future. :)
I just needed to add an -l to the grep command, according to a https://stackoverflow.com/ posting.

Code: Select all

root@porteus:/etc# find . -maxdepth 3 -type f -exec grep -l "BOOTDEV" "{}" \;
./profile.d/porteus.sh
./sudoers
root@porteus:/etc#
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

Ravas coding goodies

Post#119 by Rava » 12 Feb 2022, 06:13

^
I told you https://stackoverflow.com/ is the thing… Image or in other words, when it comes to [ code ]ing, the real deal. :D
Cheers!
Yours Rava

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

Ravas coding goodies

Post#120 by Rava » 14 Feb 2022, 00:24

Code: Select all

root@porteus:/mnt/sda2# fsck /what/ever.ext2
fsck from util-linux 2.37.3
e2fsck 1.46.5 (30-Dec-2021)
/mnt/sda99/what/ever.ext2 is mounted.



WARNING!!!  The filesystem is mounted.   If you continue you ***WILL***
cause ***SEVERE*** filesystem damage.


Do you really want to continue<n>? no
check aborted.
Just FYI, there is a good reason that fsck is printing all these empty lines for emphasis and is shouting WARNING and bolding [*] and shouting WILL and SEVERE, because it will happen, so either you want to mess with your own filesystem or need to mess with someone's else filesystem, always press n!

_________________________
In text based communications of old, e.g. emails back prior the name internet was even born [approx 1994 and earlier…, yes Rava is that old…], text was highlighted like so
*bold*
_underline_
/italic/
Cheers!
Yours Rava

Post Reply