Commit 70f30f44 authored by Luc Didry's avatar Luc Didry

Merge branch 'housekeeping' into 'master'

General housekeeping

Correct various typos.
Change GitLab URL to framagit.org.
Add USER setting for services.
Add upstart configuration.

See merge request !2
parents ec1572fb 1c5cd4dd
Pipeline #9232 failed with stage
in 4 minutes and 43 seconds
......@@ -10,17 +10,18 @@ Lstu is licensed under the terms of the WTFPL. See the LICENSE file.
## Dependencies
* Carton : Perl dependencies manager, it will get what you need, so don't bother for dependencies (but you can read the file `cpanfile` if you want).
* Carton : Perl dependencies manager, it will get what you need, so don't bother about dependencies (but you can read the file `cpanfile` if you want).
```shell
sudo cpan Carton
```
## Installation
After installing Carton :
```shell
git clone https://git.framasoft.org/luc/lstu.git
git clone https://framagit.org/luc/lstu.git
cd lstu
carton install
cp lstu.conf.template lstu.conf
......@@ -36,6 +37,7 @@ The configuration file is self-documented.
This is good for test, not for production.
```
# start it
carton exec hypnotoad script/lstu
# stop it
carton exec hypnotoad -s script/lstu
......@@ -71,13 +73,13 @@ service lstu start
There is the `contact` option (mandatory), where you have to put some way for the users to contact you, and the `secret` where you have to put a random string in order to protect your Mojolicious cookies (not really useful and optional).
Please, have a look at the `lstu.conf.template`, it's full of options and self-documented.
Please, have a look at the `lstu.conf.template`, it's full of options and is self-documented.
## How many urls can it handle ?
## How many URLs can it handle ?
By default, there are 8 361 453 672 available combinations. I think the sqlite db will explode before you reach this limit. If you want more shortened URLs than that, open `lstu.conf` and change the `length` setting.
Everytime somebody uses Lstu, it will create 'waiting' shortened URLs codes in order to be quick to shorten the URLs.
Every time somebody uses Lstu, it will create 'waiting' shortened URLs codes in order to be quick to shorten the URLs.
Accordingly to the `lstu.conf` configuration file, it will create `provisioning` waiting URLs, adding them `provis_step` by `provis_step`.
......
......@@ -54,7 +54,7 @@
<p>
<small>&copy; 2013 — 2015 <%= link_to 'Luc Didry' => 'https://fiat-tux.fr' %> —
<%= l('License:') %> <%= link_to 'WTFPL' => 'http://www.wtfpl.net/' %> —
<%= link_to l('About') => 'https://git.framasoft.org/luc/lstu#tab-readme' %> —
<%= link_to l('About') => 'https://framagit.org/luc/lstu#tab-readme' %> —
<%= link_to 'API' => url_for('api') %> —
<%= link_to l('Statistics') => url_for('stats') %>
</small>
......
# LDIR is the path where you installed Lutim
# LDIR is the path where you installed Lstu
# It has to end with a final /
LDIR=/var/www/lstu/
# USER is the user who will launch Lstu
USER=www-data
......@@ -26,6 +26,11 @@ then
echo "LDIR variable is empty, please fill it in /etc/default/lstu"
exit 0
fi
if [ -z $USER ]
then
echo "USER variable is empty, please fill it in /etc/default/lstu"
exit 0
fi
else
echo "Missing /etc/default/lstu file"
exit 0
......@@ -49,7 +54,7 @@ do_start()
# 2 if daemon could not be started
cd $LDIR
carton exec hypnotoad $DAEMON >/dev/null 2>&1
su $USER -c "carton exec hypnotoad $DAEMON >/dev/null 2>&1"
return "$?"
}
......@@ -62,7 +67,7 @@ do_stop()
# other if a failure occurred
cd $LDIR
carton exec hypnotoad -s $DAEMON >/dev/null 2>&1
su $USER -c "carton exec hypnotoad -s $DAEMON >/dev/null 2>&1"
return "$?"
}
......@@ -75,10 +80,10 @@ do_status()
if [ "$?" = "0" ]; then
log_progress_msg "$NAME is running"
else
log_progress_msg "$NAME is NOT running"
log_failure_msg "$NAME is NOT running but PID file exists"
fi
else
log_progress_msg "$NAME is NOT running"
log_failure_msg "$NAME is NOT running"
fi
}
......@@ -101,7 +106,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
......@@ -114,7 +119,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
......@@ -134,16 +139,16 @@ case "$1" in
log_end_msg 0
;;
*)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
else
log_progress_msg "$NAME is NOT running. Unable to stop"
log_failure_msg "$NAME is NOT running. Unable to stop"
log_end_msg 1
fi
else
log_progress_msg "$NAME is NOT running. Unable to stop"
log_failure_msg "$NAME is NOT running. Unable to stop"
log_end_msg 1
fi
;;
......@@ -155,13 +160,14 @@ case "$1" in
reload)
log_daemon_msg "Reloading $NAME"
do_start
sleep 1
case "$?" in
0|1)
log_progress_msg "done"
log_end_msg 0
;;
2)
log_progress_msg "failed"
log_failure_msg "failed"
log_end_msg 1
;;
esac
......@@ -169,7 +175,7 @@ case "$1" in
restart)
log_daemon_msg "Restarting $NAME"
do_stop
sleep 1
sleep 6
do_start
case "$?" in
0|1)
......@@ -177,7 +183,7 @@ case "$1" in
log_end_msg 0
;;
2)
log_progress_msg "failed";
log_failure_msg "failed";
log_end_msg 1
;;
esac
......
......@@ -22,4 +22,4 @@ server {
proxy_pass http://lstu;
proxy_redirect http://lstu https://lstu.example.org;
}
}
[Unit]
Description=Shortened URLs service
Documentation=https://git.framasoft.org/luc/lstu
Documentation=https://framagit.org/luc/lstu
Requires=network.target
After=network.target
......
# -*- upstart -*-
description "lstu"
author "Luc Didry <luc@didry.org>"
start on (networking)
stop on runlevel [!2345]
script
if [ -f "/etc/default/lstu" ]
then
. /etc/default/lstu
if [ -z $LDIR ]
then
echo "LDIR variable is empty, please fill it in /etc/default/lstu"
exit 0
fi
if [ -z $USER ]
then
echo "USER variable is empty, please fill it in /etc/default/lstu"
exit 0
fi
else
echo "Missing /etc/default/lstu file"
exit 0
fi
cd $LDIR
su $USER -c "carton exec hypnotoad -f script/lstu"
end script
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment