help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] skip a script based on own filename variable


From: adrelanos
Subject: [Help-bash] skip a script based on own filename variable
Date: Sat, 20 Apr 2013 17:56:01 +0000

Hi!

I have a folder with chroot scripts. (Scripts which are run inside a
chrooted environment.) Those are run with run-parts, which is awesome,
because their execution is sorted by name.

Some names include:
20_root_check
30_sanity_checks
...
70_update_command_not_found
...

For debug builds, I'd like to skip some of the less important chroot
scripts. I thought, if I could make some kind of build configuration,
that'd be nice. Such as

Outside:
> export 70_update_command_not_found=0

70_update_command_not_found:
> set -x

> OWN_FILENAME="$(basename $0)"

> if [ "$OWN_FILENAME" = "0" ];
>    true "INFO: Skipping $OWN_FILENAME, because $OWN_FILENAME is set to 0."
> fi

This doesn't work, because bash doesn't accept variable names starting
with numbers.

Ok, another idea...

Outside:
> export WHONIX_BUILD_CONFIG=("70_update_command_not_found")

70_update_command_not_found:
>for setting in "address@hidden"; do
>   if [ "$setting" = "$OWN_FILENAME" ]; then
>      true "INFO: Skipping $OWN_FILENAME, because $OWN_FILENAME is set
in WHONIX_BUILD_CONFIG."
>      exit 0
>   fi
>done

This doesn't work either, because according to man bash, it does not
(yet) support exporting arrays.

So I told you now, what I'd like to do and what I tried already. I am
looking for some generic code to deactivate chosen scripts by name.
(Setting some SKIP_UPDATE_COMMAND_NOT_FOUND would work, but it's not
generic.) How could I best allow deactivating any chroot script based on
variables set outside and the filename alone?

Cheers,
adrelanos



reply via email to

[Prev in Thread] Current Thread [Next in Thread]