howto:conffile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
howto:conffile [2015/08/08 15:44]
bill_thomson
howto:conffile [2015/08/08 15:53]
bill_thomson
Line 5: Line 5:
 ===== General ===== ===== General =====
  
-For this task, you don't have to write big parser routines (unless you want it 100% secure or you want a special file syntax) - you can use the Bash source command. The file to be sourced should be formated in key="​value"​ format, otherwise bash will try to interpret commands:+For this task, you don't have to write large parser routines (unless you want it 100% secure or you want a special file syntax) - you can use the Bash source command. The file to be sourced should be formated in key="​value"​ format, otherwise bash will try to interpret commands:
  
 <​code>​ <​code>​
Line 30: Line 30:
 #!/bin/bash #!/bin/bash
 echo "​Reading config...."​ >&2 echo "​Reading config...."​ >&2
-. /​etc/​cool.cfg+. /etc/cool.cfg #note the space between the dot and the leading slash of /etc.cfg
 echo "​Config for the username: $cool_username"​ >&2 echo "​Config for the username: $cool_username"​ >&2
 echo "​Config for the target host: $cool_host"​ >&2 echo "​Config for the target host: $cool_host"​ >&2
Line 37: Line 37:
 ===== Per-user configs ===== ===== Per-user configs =====
  
-There'​s also a way to provide a system-wide config file in /etc and a custom ​one in ~/ (user'​s home) to override ​some system-wide defaults. ​The user-specific config ​will only be used when present, in the following example:+There'​s also a way to provide a system-wide config file in /etc and a custom ​config ​in ~/​(user'​s home) to override system-wide defaults. ​In the following example, the if/then construct is used to check for the existance of a user-specific config:
  
 <​code>​ <​code>​
  • howto/conffile.txt
  • Last modified: 2015/08/08 16:00
  • by bill_thomson