mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Added rudimentary install script
Former-commit-id: 1fd9e5140c14be645b8eb61cdd718ec4e6d606d4 [formerly eaca16b2be31938f5115ba3947f7605a842092f1] [formerly e30ad4f19a183e93879a6525cc556e1c5f179ea8 [formerly be7674572401bf94e07e767acb00455a044026e5 [formerly107e20c283]]] Former-commit-id: e71c209ec2901c97c36f1dcee1824df31212febb [formerly 624054900645662b0b03123e124dfa59b78d240d] Former-commit-id: 8bec9da01fd8c4c5a8ab2dadf4ef75b2494ca02f Former-commit-id:0326a61781
This commit is contained in:
90
install/cowyo.init
Executable file
90
install/cowyo.init
Executable file
@@ -0,0 +1,90 @@
|
||||
|
||||
# This should be placed in /etc/init.d directory
|
||||
# start with
|
||||
# sudo /etc/init.d/shrib start
|
||||
# stop with
|
||||
# sudo /etc/init.d/shrib start
|
||||
|
||||
dir="/home/phi/Documents/cowyo"
|
||||
user="phi"
|
||||
cmd="./cowyo cowyo.duckdns.org"
|
||||
|
||||
name="cowyo2"
|
||||
pid_file="/var/run/$name.pid"
|
||||
stdout_log="/var/log/$name.log"
|
||||
stderr_log="/var/log/$name.err"
|
||||
|
||||
get_pid() {
|
||||
cat "$pid_file"
|
||||
}
|
||||
|
||||
is_running() {
|
||||
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if is_running; then
|
||||
echo "Already started"
|
||||
else
|
||||
echo "Starting $name"
|
||||
cd "$dir"
|
||||
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
|
||||
echo $! > "$pid_file"
|
||||
if ! is_running; then
|
||||
echo "Unable to start, see $stdout_log and $stderr_log"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if is_running; then
|
||||
echo -n "Stopping $name.."
|
||||
kill `get_pid`
|
||||
for i in {1..10}
|
||||
do
|
||||
if ! is_running; then
|
||||
break
|
||||
fi
|
||||
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
echo
|
||||
|
||||
if is_running; then
|
||||
echo "Not stopped; may still be shutting down or shutdown may have failed"
|
||||
exit 1
|
||||
else
|
||||
echo "Stopped"
|
||||
if [ -f "$pid_file" ]; then
|
||||
rm "$pid_file"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Not running"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
if is_running; then
|
||||
echo "Unable to stop, will not attempt to start"
|
||||
exit 1
|
||||
fi
|
||||
$0 start
|
||||
;;
|
||||
status)
|
||||
if is_running; then
|
||||
echo "Running"
|
||||
else
|
||||
echo "Stopped"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
10
install/install.sh
Executable file
10
install/install.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
apt-get update
|
||||
apt-get install nginx
|
||||
cp cowyo.nginx /etc/nginx/sites-available/
|
||||
cp cowyo.init /etc/init.d/
|
||||
ln -s /etc/nginx/sites-available/cowyo.nginx /etc/nginx/sites-enabled/cowyo.nginx
|
||||
service nginx reload && service nginx restart
|
||||
cd ../
|
||||
go build
|
||||
service cowyo.init start
|
||||
|
||||
Reference in New Issue
Block a user