Last active
November 22, 2016 16:08
-
-
Save kblomqvist/e61249f2585e0f26de2d0336c2296c7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
su root | |
apt-get install postgresql postgresql-client # cluster named as 'main' will be created automatically | |
adduser pgweb --disabled-login --disabled-password --shell /usr/sbin/nologin | |
apt-get install unzip | |
su pgweb -s /bin/bash | |
cd | |
wget https://github.com/sosedoff/pgweb/releases/download/v0.9.6/pgweb_linux_amd64.zip | |
unzip pgweb_linux_amd64.zip | |
mv pgweb_linux_amd64 pgweb | |
touch .pgweb/bookmarks/server.toml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: pgweb | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start daemon at boot time | |
# Description: Enable service provided by daemon. | |
### END INIT INFO | |
# Installation instructions | |
# | |
# Save this script into /etc/init.d/pgweb file and make the file | |
# executable and installing it into the boot sequence: | |
# | |
# chmod 755 /etc/init.d/pgweb | |
# update-rc.d pgweb defaults | |
# | |
# This script assumes that pgweb binary is located at /home/pgweb directory, | |
# and that there's a bookmark named server in /home/pgweb/.pgweb/bookmarks. | |
# | |
NAME="pgweb" | |
PIDFILE="/var/run/$NAME.pid" | |
USER="pgweb" # Linux system user | |
SU="su $USER -s /bin/bash" | |
TIMEOUT=5 # Time in seconds to wait postgresql to show up | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ]; then | |
echo "Already running... cat $PIDFILE" | |
exit 0 | |
fi | |
# Wait postgresql to show up | |
while ! test -f /var/run/postgresql/*main.pid | |
do | |
sleep 1 | |
TIMEOUT=`expr $TIMEOUT - 1` | |
if test $TIMEOUT -eq 0; then | |
exit 1 | |
fi | |
done | |
# Ready to start pgweb | |
PID=`$SU -c '/home/pgweb/pgweb --lock-session -b server >/dev/null & echo $!'` # Note! Logs are lost. | |
if [ -z $PID ]; then | |
exit 1 | |
else | |
echo $PID > $PIDFILE | |
fi | |
;; | |
stop) | |
PID=`cat $PIDFILE` | |
kill $PID && rm $PIDFILE | |
;; | |
*) | |
echo "Usage: /etc/init.d/$NAME {start|stop}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment