PhotoBackup / server-perl

The Perl PhotoBackup server implementation
https://photobackup.github.io/
Other
1 stars 2 forks source link

Wrapper script? Installation instructions? #2

Open inspector71 opened 3 years ago

inspector71 commented 3 years ago

PhotoBackup looks like my sort of thinking. Mobile app merely copying images to my server. Brilliant. Except the server part.

This Perl lib is sensational work and arguably I would ideally have the time and headspace to implement a wrapper around it. However, no sense re-writing the wheel, to butcher a phrase. Is there an ubuntu / debbie package to install or a wrapper script I can set up?

Guessing some installation instructions would be great. If there is nothing out there, I can have a go and see if my efforts are worth documenting for the greater good.

d5ve commented 3 years ago

Hi, thanks for your interest in the perl server.

It's been a while since I last installed and ran the perl server for PhotoBackup, as I switched to using self-hosted nextcloud to backup photos and videos from my phone.

The way I used to install and run things was something like the below, which used an init script, and ran the server as a non-privileged user. These days I would probably have wrapped the whole thing in docker.

root> cpanm Net::PhotoBackup::Server

root> cat << EOF > /etc/init.d/photobackup-perl
#!/bin/bash
### BEGIN INIT INFO
# Provides:          photobackup-perl
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Should-Start:      $network
# Should-Stop:       $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts PhotoBackup perl service as user myuser.
# Description:       Runs photobackup.pl as myuser to start
#                    the PhotoBackup PSGI app.
### END INIT INFO

USER=myuser
DIR=/home/$USER

PIDFILE=$DIR/.photobackup.pid

case "$1" in
  start)
    start-stop-daemon --start --chuid $USER --chdir $DIR  \
        --pidfile=$PIDFILE \
        --exec /usr/local/bin/photobackup.pl -- run
    ;;
  stop)
    start-stop-daemon --stop --pidfile $PIDFILE
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop}" >&2
    exit 3
    ;;
esac
EOF

root> su - myuser

myuser> /usr/local/bin/photobackup.pl init

myuser> exit

root> update-rc.d photobackup-perl defaults

root> invoke-rc.d photobackup-perl restart

I hope this is helpful, and please let me know if you have any questions or suggestions.

Dave

inspector71 commented 3 years ago

Hi Dave

Thank you so very much for your much appreciated, super helpful reply.

It is not often I read such nice, neutral, helpful words online.

Have been considering Nextcloud for a while, indirectly. Not yet a Docker user so with many installation guides defaulting to Docker these days, has made it harder.

Interested in Nextcloud but uncertain if secure enough to run on a public-facing VPS or home server. Have no evidence to suggest it is not. Just my default anxiety around security matters.

On Sun., 7 Mar. 2021, 2:06 pm Dave Webb, @.***> wrote:

Hi, thanks for your interest in the perl server.

It's been a while since I last installed and ran the perl server for PhotoBackup, as I switched to using self-hosted nextcloud to backup photos and videos from my phone.

The way I used to install and run things was something like the below, which used an init script, and ran the server as a non-privileged user. These days I would probably have wrapped the whole thing in docker.

root> cpanm Net::PhotoBackup::Server

root> cat << EOF > /etc/init.d/photobackup-perl

!/bin/bash

BEGIN INIT INFO

Provides: photobackup-perl

Required-Start: $local_fs $remote_fs

Required-Stop: $local_fs $remote_fs

Should-Start: $network

Should-Stop: $network

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Starts PhotoBackup perl service as user myuser.

Description: Runs photobackup.pl as myuser to start

the PhotoBackup PSGI app.

END INIT INFO

USER=myuser DIR=/home/$USER

PIDFILE=$DIR/.photobackup.pid

case "$1" in start) start-stop-daemon --start --chuid $USER --chdir $DIR \ --pidfile=$PIDFILE \ --exec /usr/local/bin/photobackup.pl -- run ;; stop) start-stop-daemon --stop --pidfile $PIDFILE ;; *) echo "Usage: $SCRIPTNAME {start|stop}" >&2 exit 3 ;; esac EOF

root> su - myuser

myuser> /usr/local/bin/photobackup.pl init

myuser> exit

root> update-rc.d photobackup-perl defaults

root> invoke-rc.d photobackup-perl restart

I hope this is helpful, and please let me know if you have any questions or suggestions.

Dave

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PhotoBackup/server-perl/issues/2#issuecomment-792184668, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJKSC7KV3PW6PBNOBA3P6LTCLURVANCNFSM4YXKNXMA .