-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetupConfig.sh
More file actions
51 lines (40 loc) · 1.03 KB
/
setupConfig.sh
File metadata and controls
51 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# a shorthand script to set up config and template aliases at once
# just makes life on the command line easier
if [ -z $1 ]
then
echo "Have to pass a config name (with path)! Exiting."
return 1;
fi
cfgName="$1"
export cfg=${cfgName}
if ! [ -f $cfg ]
then
echo
echo "Found no config with name $cfgName!"
echo "Maybe you meant something like this (listing search with wildcards)? :"
echo
echo "------------- "
ls -lhrt *$cfgName*
echo "------------- "
echo
echo "Try again."
return 1;
fi
tplName="$(grep tpl $cfg | cut -d= -f2 )"
if ! [ -f $(dirname $cfg)/$tplName ]
then
echo
echo "Found no template with name $tplName!"
echo "Maybe you meant something like this (listing search with wildcards)? :"
echo
echo "------------- "
ls -lhrt $(dirname $cfg)/*$tplName*
echo "------------- "
echo
echo "Try again."
return 1;
fi
export tpl=$(ls $(dirname $cfg)/$(grep tpl $cfg | cut -d= -f2 ))
echo "Using config $cfg"
echo "Using template $tpl"