Files
Glimmer/deploy/urlshort.init
T
lucioandClaude Sonnet 4.6 60a09fa878 Initial commit: URL shortener + pastebin with dark admin UI and deploy scripts
Features:
- URL shortener with QR codes, click tracking, deduplication, rate limiting
- Pastebin with Markdown rendering, access tokens, raw view
- Admin dashboard: dark theme, stats bar, Quick Links tiles with favicons,
  card-based layout, format/token badges, empty states
- CSRF protection, bcrypt auth, in-memory sessions, security headers
- Pure-Go SQLite (no CGo), single self-contained binary

Deploy:
- deploy/install.sh: auto-detects systemd vs SysV init
- deploy/urlshort.service: hardened systemd unit
- deploy/urlshort.init: SysV init script for older Ubuntu

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-02 03:00:08 -07:00

72 lines
1.6 KiB
Bash

#!/bin/sh
### BEGIN INIT INFO
# Provides: urlshort
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: URL Shortener
# Description: URL Shortener and Pastebin server
### END INIT INFO
NAME=urlshort
DAEMON=/opt/urlshort/urlshort
DAEMON_ARGS="-config /etc/urlshort/config.toml"
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log
RUN_AS=urlshort
. /lib/lsb/init-functions
do_start() {
if [ ! -x "$DAEMON" ]; then
log_failure_msg "$DAEMON not found or not executable"
return 1
fi
start-stop-daemon --start --quiet \
--pidfile "$PIDFILE" --make-pidfile \
--background --no-close \
--chuid "$RUN_AS" \
--exec "$DAEMON" -- $DAEMON_ARGS \
>> "$LOGFILE" 2>&1
return $?
}
do_stop() {
start-stop-daemon --stop --quiet \
--pidfile "$PIDFILE" \
--retry=TERM/10/KILL/5
RETVAL=$?
rm -f "$PIDFILE"
return $RETVAL
}
case "$1" in
start)
log_daemon_msg "Starting $NAME"
do_start
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $NAME"
do_stop
log_end_msg $?
;;
restart|force-reload)
log_daemon_msg "Restarting $NAME"
do_stop
sleep 1
do_start
log_end_msg $?
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME"
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0