apex-source-control/scripts/generate-app-id
2018-12-28 17:10:39 -05:00

38 lines
1.2 KiB
Plaintext
Executable File

# designed to be called from top level project dir
script_folder=$(dirname $0)
source config/asc.conf || exit 1
if which -s sql; then
echo Running PWD $PWD
sql_cmd="sql -S"
else
echo WARNING: could not find SQLcl \(sql\). Falling back to sqlplus
sql_cmd="sqlplus -S"
fi
tmpfile=$(mktemp -t generate_app_id)
echo ${sql_cmd} ${username}/${password}@${database_connection} @${script_folder}/generate_new_app_id.sql $tmpfile || exit 1
${sql_cmd} ${username}/${password}@${database_connection} @${script_folder}/generate_new_app_id.sql > $tmpfile || exit 1
app_id=$(cat $tmpfile)
rm $tmpfile
if [ -h config/asc.conf ]; then
conf_file=$(readlink ./config/asc.conf)
echo -n "The id '${app_id}' will be written to '${conf_file}'. Is this alright? [y/N]: "
read can_write
if [ "${can_write}" == "y" ]; then
sed -i "s/^apexappid=.*/apexappid=${app_id}/" config/${conf_file}
echo "apexappid in '${conf_file}' has been replaced with '${app_id}'. The new config file looks like this: "
cat config/${conf_file}
else
echo -n "The generated app id was not written to file. "
echo "You can change this manually by changing the apexappid of your config to '${app_id}'"
fi
fi
rm -f config/new_app_id.txt