-
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.
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
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:
${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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

Samsung 2.5" 870 EVO SSD SATA III 250GB 500GB 1TB Internet Solid State Drive Lot
$100.00

Western Digital Blue 3D NAND 500GB Internal 2.5" SSD - WDS500G2B0A
$49.99

Samsung 860 EVO 250GB SSD MZ-76E250 2.5" SATA III Solid State Drive -
$36.99

Intel Solid-State Drive DC S3500 Series 240GB Internal 2.5" (SSDSC2BB240G4P) SSD
$29.99

Fanxiang 256GB 512GB 1TB 2TB 4TB SSD Lot 2.5'' SATA Internal Solid State Drive
$42.99

2 PACK 128 GB SSD M.2 2280 SATA Solid State Drive Major Brands, Samsung, LiteON
$28.00

Netac 2TB 1TB 512GB 256GB Internal SSD 2.5inch SATAIII Solid State Drive lot
$259.00

Fanxiang 1/2/5/10Pcs 2.5'' SATA SSD Lot 1TB 2TB 4TB 512GB 256GB TLC Internal SSD
$129.99

Netac 120GB 256GB 1TB 2TB Internal SSD 2.5'' SATAIII 6Gb/s Solid State Drive lot
$119.99

Netac 256GB SSD 2.5'' SATA III 6Gb/s Internal Solid State Drive 500MB/s PC/Latop
$40.00