Skip to main content
Post Closed as "Needs details or clarity" by Hauke Laging, ReflectYourCharacter, Stephen Kitt, GAD3R, Archemar
added 966 characters in body
Source Link
user447274
  • 539
  • 2
  • 10

In Linux, using Bash, I have two scripts:

  1. script.sh is the main script, and
  2. script_config.sh is the configuration for script.sh.

In script.sh, I do source script_config.sh to load all the config from there.

In script_config.sh, I do things like:

TEMPDIR=/mnt/sda1/temp 

I don’t know if this is the best way, but for me it’s okay, I have the config in a separate file and can load it into the main script.

In an old version of script.sh, I used shuf to read a file (cipher_to_use.txt) to get random input for which cipher to use with cryptsetup.

In cipher_to_use.txt, there are only 6 different ciphers listed, but some lines appear up to 10 times, so shuf chooses them more often but still randomly. That works okay for me.

But now, with script_config.sh, I’m looking for a way to continue this approach,
but I don’t want to write the 6 ciphers more than once in script_config.sh.

How can I use different ciphers with shuf, but make some appear more often than others, while listing each cipher only once in script_config.sh?

:edit

thanks nbanana for your ideas, but is there a way to make it a little bit different from your way?

if i write in script_config.sh this:

(chk = cipher has key)

chk1_name_="--cipher aes-cbc-essiv:sha256 --hash sha512 --key-size 256" chk1_weigt="15" chk2_name_="--cipher serpent-cbc-essiv:sha256 --hash sha512 --key-size 256" chk2_weigt="1" chk3_name_="--cipher twofish-cbc-essiv:sha256 --hash sha512 --key-size 256" chk3_weigt="1" chk4_name_="--cipher aes-xts-plain64 --hash sha512 --key-size 512" chk4_weigt="4" chk5_name_="--cipher serpent-xts-plain64 --hash sha512 --key-size 512" chk5_weigt="1" chk6_name_="--cipher twofish-xts-plain64 --hash sha512 --key-size 512" chk6_weigt="1" 

what have i to add in script.sh to become a ciphers_has_key_list-file

whit 15times in chk1, 1 chk2, and so on... ?

what if, if chk6 does not exist anymore?

what if, if there a chk7 and a chk8 ?

In Linux, using Bash, I have two scripts:

  1. script.sh is the main script, and
  2. script_config.sh is the configuration for script.sh.

In script.sh, I do source script_config.sh to load all the config from there.

In script_config.sh, I do things like:

TEMPDIR=/mnt/sda1/temp 

I don’t know if this is the best way, but for me it’s okay, I have the config in a separate file and can load it into the main script.

In an old version of script.sh, I used shuf to read a file (cipher_to_use.txt) to get random input for which cipher to use with cryptsetup.

In cipher_to_use.txt, there are only 6 different ciphers listed, but some lines appear up to 10 times, so shuf chooses them more often but still randomly. That works okay for me.

But now, with script_config.sh, I’m looking for a way to continue this approach,
but I don’t want to write the 6 ciphers more than once in script_config.sh.

How can I use different ciphers with shuf, but make some appear more often than others, while listing each cipher only once in script_config.sh?

In Linux, using Bash, I have two scripts:

  1. script.sh is the main script, and
  2. script_config.sh is the configuration for script.sh.

In script.sh, I do source script_config.sh to load all the config from there.

In script_config.sh, I do things like:

TEMPDIR=/mnt/sda1/temp 

I don’t know if this is the best way, but for me it’s okay, I have the config in a separate file and can load it into the main script.

In an old version of script.sh, I used shuf to read a file (cipher_to_use.txt) to get random input for which cipher to use with cryptsetup.

In cipher_to_use.txt, there are only 6 different ciphers listed, but some lines appear up to 10 times, so shuf chooses them more often but still randomly. That works okay for me.

But now, with script_config.sh, I’m looking for a way to continue this approach,
but I don’t want to write the 6 ciphers more than once in script_config.sh.

How can I use different ciphers with shuf, but make some appear more often than others, while listing each cipher only once in script_config.sh?

:edit

thanks nbanana for your ideas, but is there a way to make it a little bit different from your way?

if i write in script_config.sh this:

(chk = cipher has key)

chk1_name_="--cipher aes-cbc-essiv:sha256 --hash sha512 --key-size 256" chk1_weigt="15" chk2_name_="--cipher serpent-cbc-essiv:sha256 --hash sha512 --key-size 256" chk2_weigt="1" chk3_name_="--cipher twofish-cbc-essiv:sha256 --hash sha512 --key-size 256" chk3_weigt="1" chk4_name_="--cipher aes-xts-plain64 --hash sha512 --key-size 512" chk4_weigt="4" chk5_name_="--cipher serpent-xts-plain64 --hash sha512 --key-size 512" chk5_weigt="1" chk6_name_="--cipher twofish-xts-plain64 --hash sha512 --key-size 512" chk6_weigt="1" 

what have i to add in script.sh to become a ciphers_has_key_list-file

whit 15times in chk1, 1 chk2, and so on... ?

what if, if chk6 does not exist anymore?

what if, if there a chk7 and a chk8 ?

Fix title and text
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

dont know the right topic at the moment How can I pick random items from a list, please editbut some more often than others, thanks!in a Bash config file?

In Linux in bash i, using Bash, I have two scripts.

script.sh is the main script and:

script_config.sh is the configuration for script.sh.

  1. script.sh is the main script, and
  2. script_config.sh is the configuration for script.sh.

In script.sh i, I do source script_config.sh to haveload all the config infrom there.

In script_config.sh i, I do things like:

TEMPDIR=/mnt/sda1/temp

TEMPDIR=/mnt/sda1/temp 

DontI don’t know if this a goodis the best way, but for me is it okeit’s okay, iI have the config in an extraa separate file and can load it into the main script.

In aan old version of script.sh i use, I used shuf to read a file (cipher_to_use.txt) to becomeget random input what chipper isfor which cipher to use with crytpsetupcryptsetup.

In cipher_to_use.txt, there are only 6 different ciphers write downlisted, but some lines areappear up to 10times in theree becouse10 times, so shuf usechooses them more often but chose it everytimestill randomly, thats. That works okeokay for me.

But now, with scipt_configscript_config.sh i am, I’m looking for a way to continue this approach,
but i will not write the 6 ciphers from cipher_to_use.txt more than onetime in to the script_config.sh filebut I don’t want to write the 6 ciphers more than once in script_config.sh.

How can iI use different ciphers with shuf, but make some appear more often than orthersothers, while listing each cipher only once in script_config.shscript_config.sh?

dont know the right topic at the moment, please edit, thanks!

In Linux in bash i have two scripts.

script.sh is the main script and

script_config.sh is the configuration for script.sh.

In script.sh i do source script_config.sh to have all the config in there.

In script_config.sh i do things like

TEMPDIR=/mnt/sda1/temp

Dont know if this a good way, but for me is it oke, i have the config in an extra file can load it into the main script.

In a old version of script.sh i use shuf to read a file (cipher_to_use.txt) to become random input what chipper is to use with crytpsetup.

In cipher_to_use.txt are only 6 different ciphers write down, but some lines are up to 10times in theree becouse shuf use them more but chose it everytime randomly, thats works oke for me.

But now, with scipt_config.sh i am looking for a way to continue this but i will not write the 6 ciphers from cipher_to_use.txt more than onetime in to the script_config.sh file

How can i use different ciphers with shuf, but some more than orthers in script_config.sh?

How can I pick random items from a list, but some more often than others, in a Bash config file?

In Linux, using Bash, I have two scripts:

  1. script.sh is the main script, and
  2. script_config.sh is the configuration for script.sh.

In script.sh, I do source script_config.sh to load all the config from there.

In script_config.sh, I do things like:

TEMPDIR=/mnt/sda1/temp 

I don’t know if this is the best way, but for me it’s okay, I have the config in a separate file and can load it into the main script.

In an old version of script.sh, I used shuf to read a file (cipher_to_use.txt) to get random input for which cipher to use with cryptsetup.

In cipher_to_use.txt, there are only 6 different ciphers listed, but some lines appear up to 10 times, so shuf chooses them more often but still randomly. That works okay for me.

But now, with script_config.sh, I’m looking for a way to continue this approach,
but I don’t want to write the 6 ciphers more than once in script_config.sh.

How can I use different ciphers with shuf, but make some appear more often than others, while listing each cipher only once in script_config.sh?

Source Link
user447274
  • 539
  • 2
  • 10

dont know the right topic at the moment, please edit, thanks!

In Linux in bash i have two scripts.

script.sh is the main script and

script_config.sh is the configuration for script.sh.

In script.sh i do source script_config.sh to have all the config in there.

In script_config.sh i do things like

TEMPDIR=/mnt/sda1/temp

Dont know if this a good way, but for me is it oke, i have the config in an extra file can load it into the main script.

In a old version of script.sh i use shuf to read a file (cipher_to_use.txt) to become random input what chipper is to use with crytpsetup.

In cipher_to_use.txt are only 6 different ciphers write down, but some lines are up to 10times in theree becouse shuf use them more but chose it everytime randomly, thats works oke for me.

But now, with scipt_config.sh i am looking for a way to continue this but i will not write the 6 ciphers from cipher_to_use.txt more than onetime in to the script_config.sh file

How can i use different ciphers with shuf, but some more than orthers in script_config.sh?