Dear members,
The script knoppix.sh should be put in the folder KNOPPIX (when the DOK is mounted under windows)
Thanks,
Zvika.
Hello,
I'm booting Knoppix 6.7.1 from DOK.
The image on this media was created using a live CD.
Then I changed syslinux.cfg in 6.7.1 and now knoppix enters runlevel 2 (text mode) by default.
Upon entering this level I want to run my script.
So I added:
echo "My script"
in /etc/rc.local
But "My script" is not displayed.
According to another thread in this forum I tried putting my script in :
/opt/knx/knoppix/KNOPPIX/knoppix.sh
But this does not work also.
Can you help ?
Thanks,
Zvika.
Dear members,
The script knoppix.sh should be put in the folder KNOPPIX (when the DOK is mounted under windows)
Thanks,
Zvika.
Hi, Anyone know a way to inhibit execution of knoppix.sh with a boot command/cheatcode? This is useful when working on devices where you might not want your regular script to run.
You cannot inhibit the script knoppix.sh, but you can decide within this script what to do.
Append any cheatcode, for exampleIn your script "knoppix.sh" test for existence of your cheatcode byCode:knoppix no_myscriptIf the cheatcode is found, do nothing else; otherwise execute remaining of the script.Code:cat /proc/cmdline
Good idea Werner, thanks for the suggestion!
Here is my detailed explanation for novices, and a working code sample (tested on v6.7.1dvd), for those who wish to use this method:
knoppix.sh is executed during startup by a block of code that can be seen at the end of /etc/init.d/knoppix-autoconfig. If one wishes to undertake a deep remastering, it is possible to modify this code to build a script-inhibiting cheatcode into the system.
Alternatively, a conditional code block can be inserted at the start of knoppix.sh to parse /proc/cmdline, the kernel boot instructions, for a specified keyword, for example no_myscript. Use this keyword as you would a cheatcode, by typing knoppix no_myscript at the boot prompt, and the code shown below will suspend script execution; if the keyword is not entered, the script will execute as per normal.
Note that knoppix.sh is not executed in Bash, but in a Bourne shell, so some more common Bash commands that check whether a variable contains certain text will not work properly; for instance, grep will not work, nor will [[ "$string" == *no_myscript* ]]. Hence my use of the clever method published by one ephemient on a thread at stackoverflow, and described by him as follows:Code:string=$(cat /proc/cmdline); # Assign output of 'cat' to variable 'string'. if [ "$string" != "${string/no_myscript}" ]; then # Check for presence of keyword. echo "Stopping Script" exit else echo "Running Script" fi
${var/search/replace} is $var with the first instance of search replaced by replace, if it's found (it doesn't change $var). If you try to replace [no_myscript] by nothing, and the string has changed, then obviously [no_myscript] was found.
If you use within Knoppix the shebang-lineNote that knoppix.sh is not executed in Bash, but in a Bourne shellyou'll get the Bash. '/bin/sh' is only a symlink to '/bin/bash'Code:#!/bin/sh
I see, and appreciate your input; as a novice myself I welcome and encourage criticism and instruction from others who know their stuff.
My comment was an inference based on the fact that certain alternative methods of checking for the presence of text in a string var worked in LXTerminal, but not in the lower runlevel root terminal at startup. Why is this the case?
I noticed that the shebang-line in /etc/init.d/knoppix-autoconfig invokes #!/bin/busybox sh. Does knoppix.sh therefore run in Busybox/Almquist shell, rather than Bash or sh?
While booting Knoppix only busybox is available (here '#!/bin/sh' is a symlink to busybox). After completion of bootprocess you can use Bash.
Within the init-script of minirt.gz you can see, how KK solved the problem using the function "checkbootparam()"
In the script knoppix.sh you can use a line like this:
Code:cat /proc/cmdline | grep -q "no_myscript" && exit
Yes, your code above works at boot, and is more elegant.
My initial attempt with grep used a different syntax which worked in Bash but returned an error at boot, hence my incorrect statement that "grep will not work" in a post above; grep function is included in BusyBox and will indeed work at boottime.
Sure it is elegant! As regards busybox, I'm not so sure: As soon as main file system is mounted, I would think bash is available. So, Klaus K's reason for explicitly using /bin/busybox may, for example, be to have the same semantics during the whole init process. During minirt init, he has made only busybox available (other booting procedures stuff lots of core utilities into that image), and busybox does its things somewhat differently from standard gnu coreutils.
Also, what commands busybox contains and not depends on the compilation. You may find that other versions can have more or fewer commands than this one, which I think may be the standard Debian version.
ASUS H170M-PLUS Motherboard M-ATX Intel H170 LGA1151 DDR4 SATA3 HDMI DVI-D VGA
$47.99
Asus H81M-C Intel LGA1150 DDR3 Desktop Motherboard MicroATX Socket H3
$23.99
ASRock B550M Pro SE AM4 DDR4 SATA 6Gb/s 1 PCIe 4.0 x16 Micro ATX Motherboard
$84.99
Gigabyte Ultra Durable B550 GAMING X V2 Desktop Motherboard
$84.99
MSI PRO B650-P WiFi AMD AM5 DDR5 WiFi 6E ProSeries Motherboard
$96.01
ASUS P8B75-M/CSM Desktop Motherboard Intel Socket LGA1155 DDR3 w/ IO
$29.99
ASUS Q87M-E/CSM Intel Q87 Chipset DDR3 mATX LGA1150 Motherboard w/ I/O Shield
$29.95
GIGABYTE GA-X99-UD4P MOTHERBOARD, M.2 SATA3, LGA2011-3, DDR4, & I/O Shield
$69.99
MSI PRO B650-P WiFi AMD AM5 DDR5 WiFi 6E ProSeries Motherboard
$84.96
Asrock Z390 Phantom Gaming 4S/AC Wifi 8th/9th Gen Intel 1151 Motherboard Bulk
$40.92