S
S
Sergey Sashkin2018-12-06 01:29:36
bash
Sergey Sashkin, 2018-12-06 01:29:36

How to pass bash arguments to script and keep config formatting inside script?

Hello!
Guys, how do I want the script to receive arguments that it will substitute into variables inside the script
and how to save the formatting of the config so that it generates it already with the necessary parameters?
Example:
script.sh /patch/to/dst/folder 100M
Coffing itself
/var/log/messages {
rotate 5
weekly
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
"/var/log/httpd/access.log" {
rotate 5
mail www [at] my.org
size 100M
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
endscript
}
/var/log/news/* {
monthly
rotate 2
olddir /var/log/news/old
missingok
postrotate
kill -HUP `cat /var/run/inn.pid`
endscript
nocompress
}
~/log/*.log {}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
q2zoff, 2018-12-06
@LexPex

Use the variables ${n}, where n is the ordinal number of the argument. For example, ${1} would contain the string "/patch/to/dst/folder".

A
Alexander Taratin, 2018-12-06
@Taraflex

https://stackoverflow.com/questions/2914220/bash-t...
https://github.com/wercker/step-bash-template
bash template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question