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.
Dell PowerEdge R730xd Server 2.60Ghz 32-Core 64GB 800GB SSD Debian Linux
$836.80
Watchguard XCS 570 Firewall SuperMicro 1U Server Intel 4GB VPN Router LINUX 🍁
$182.65
1U BareMetal pfsense opnsense Router Firewall DNS Server 6x 10GB Ethernet Ports
$149.00
PFSENSE 15" Depth Server Router Firewall Supermicro X11SSH-F E3-1240 V5 32GB RAM
$382.00
Domino Lotus Server 5.0.7 for OS/2 WSeB, RH Linux 6, Solaris, AIX, HP-UX, Win NT
$60.00
Red Hat Enterprise Linux 5 Server - New and Sealed
$16.99
IBM CS821 20-Core 2.827GHz 128Gb 1.92Tb SSD 1U Linux Server - 8005-12N Power 8
$449.96
IBM E850 Power8 2x 12C 3.02GHz 512Gb 1.8Tb SAS 10GbE 16Gb Linux Server 8408-E8E
$674.96
SQL Server 2019 Standard (10 CAL) - Windows and Linux, Physical License
$249.00
Barracuda BBS490a / BNHW004 Backup Server No HDD with Power Cord
$249.99