-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-config
executable file
·91 lines (78 loc) · 2.74 KB
/
add-config
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Author - [email protected]
# Purpose - Add configuration files easily using prompts.
# Note - This assumes you have already run the setup script and are inside a release dir
henchman_version="v2.0.2"
henchman_location="./lib/"
henchman_debug=false
main() {
local release_dir
local setup_dir
local config_file
local database
local database_host
local database_schema
local database_user
local database_password
hm get_working_directory && release_dir=${hm_return}
echo "Name of the config file to create (typically name of schema):"
read config_filename
config_file="config/${config_filename}"
if [ -f ${config_file} ];
then
echo "This config file already exists. Goodbye."
exit 1
fi
echo "MySQL or PostgreSQL? [m/p]:"
read database_type
case ${database_type} in
'm')
echo "You selected MySQL."
database='mysql'
;;
'p')
echo "You selected PostgreSQL."
database='postgresql'
;;
*)
echo "Must enter either 'm' or 'p'. Goodbye."
exit 1
;;
esac
echo "Database host (leave blank if using PostgreSQL on this host):"
read database_host
echo "Database schema:"
read database_schema
echo "Database user:"
read database_user
echo "Database password (use .pgpass if using PostgreSQL but supply arbitrary value here):"
read -s database_password
cat << CONFIG
type=${database}
host=${database_host}
schema=${database_schema}
user=${database_user}
password=************
CONFIG
echo -e "\nDoes that look OK? ('y' will continue the experience)\n"
read -s -n 1 confirmation
if [[ "${confirmation}" == "y" || "${confirmation}" == "Y" ]]
then
touch ${config_file}
cat << CONFIG > ${config_file}
type=${database}
host=${database_host}
schema=${database_schema}
user=${database_user}
password="${database_password}"
CONFIG
else
echo "Aborting. Goodbye."
exit 1
fi
echo "All done."
echo "If you haven't configured the cron job yet give this a go:"
echo "0 3 * * * cd $(pwd) && ./donut"
}
henchman_load() { local hm_url="https://raw.githubusercontent.com/castiron/henchman/${henchman_version}/henchman";local hm_local_file="${henchman_location}/henchman-${henchman_version}";echo -e "Attempting to fetch Henchman ${henchman_version}\n";if [ -e ${hm_local_file} ];then echo -e "Henchman ${henchman_version} is ready for action.";else if hash curl 2>/dev/null;then curl ${hm_url} -o ${hm_local_file};elif hash wget 2>/dev/null;then wget ${hm_url} -O ${hm_local_file};else echo "Error! curl or wget required to fetch Henchman.";fi;fi;source ${hm_local_file}; }
henchman_load $@