add store

This commit is contained in:
Cold-Egg
2019-12-31 14:56:05 -05:00
parent cb6b1f1c78
commit 56d8d35387
+18 -2
View File
@@ -49,7 +49,21 @@ display_credential(){
echo "Username: ${SQL_USER}" echo "Username: ${SQL_USER}"
echo "Password: $(echo ${SQL_PASS} | tr -d "'")" echo "Password: $(echo ${SQL_PASS} | tr -d "'")"
fi fi
exit 0 }
store_credential(){
if [ -d "./sites/${1}" ]; then
if [ -f ./sites/${1}/.db_pass ]; then
mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk
fi
cat > "./sites/${1}/.db_pass" << EOT
"Database":"${SQL_DB}"
"Username":"${SQL_USER}"
"Password":"$(echo ${SQL_PASS} | tr -d "'")"
EOT
else
echo "./sites/${1} not found, abort credential store!"
fi
} }
add_sql_client(){ add_sql_client(){
@@ -81,6 +95,7 @@ auto_setup_main(){
check_db_access check_db_access
db_setup db_setup
display_credential display_credential
store_credential ${DOMAIN}
} }
specify_setup_main(){ specify_setup_main(){
@@ -88,6 +103,7 @@ specify_setup_main(){
check_db_access check_db_access
db_setup db_setup
display_credential display_credential
store_credential ${DOMAIN}
} }
check_input ${1} check_input ${1}
@@ -115,7 +131,7 @@ while [ ! -z "${1}" ]; do
shift shift
done done
if [ "${DOMAIN}" = '' ]; then if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then
specify_setup_main specify_setup_main
else else
auto_setup_main auto_setup_main