summaryrefslogtreecommitdiff
path: root/temp-postgres.sh
diff options
context:
space:
mode:
Diffstat (limited to 'temp-postgres.sh')
-rwxr-xr-xtemp-postgres.sh17
1 files changed, 16 insertions, 1 deletions
diff --git a/temp-postgres.sh b/temp-postgres.sh
index 8504257..96f90d2 100755
--- a/temp-postgres.sh
+++ b/temp-postgres.sh
@@ -26,6 +26,10 @@ quit() {
( >&2 printf "temp-postgres: failed to remove temporary directory: %s\\n" "${tmpdir}" )
[ "${code}" -ne 0 ] || code=1
}
+ [ -z "${symlink:-}" ] || ! [ -L "$symlink" ] || unlink "$symlink" || {
+ ( >&2 printf "temp-postgres: failed to unlink %s\\n" "$symlink" )
+ [ "${code}" -ne 0 ] || code=1
+ }
exit "${code}"
}
@@ -35,7 +39,7 @@ username="$( id -un )"
while [ $# -gt 0 ] ; do
case "$1" in
-h|--help)
- echo "Usage: temp-postgres [-h|--help] [-d|--dbname <dbname>] [-u|--username <username>] [--] [<command>]"
+ echo "Usage: temp-postgres [-h|--help] [-d|--dbname <dbname>] [-u|--username <username>] [--symlink <path>] [--] [<command>]"
exit
;;
-d|--dbname)
@@ -46,6 +50,10 @@ while [ $# -gt 0 ] ; do
username="$2"
shift 2
;;
+ --symlink)
+ symlink="$2"
+ shift 2
+ ;;
--)
shift
break
@@ -89,6 +97,13 @@ createdb --host="${tmpdir}" --username="${username}" --no-password "${dbname}" |
quit 1
}
+if [ -n "${symlink:-}" ] ; then
+ ln -sf "${tmpdir}" "$symlink" || {
+ ( >&2 printf "temp-postgres: failed to create symlink %s\\n" "$symlink" )
+ quit 1
+ }
+fi
+
printf '
Connect with the following command:
Generated by cgit. See skreutz.com for my tech blog and contact information.