Shaarli is a single user link sharing service. It stores its data on filesystem and does not need a database server. It is a very light solution of a single user working alone outside of a group.

This howto is tested on:

  • Debian 10.0 Buster

This howto is tested with these versions of the software:

  • 0.12.1

Requirements

Settings

Set the software hosting domain name:

domain='links.domain.com'

Set the method used to setup a HTTPS connnection: “auto” to automatically create a free “Let’s Encrypt (en)” SSL certificate, or the name of a SSL certificate created as described by Create a SSL / TLS certificate on Debian (optional, recommended):

sslKeyName='auto'

Installation

Detect if sudo is available (“command” is used if not):

cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'

Set the software code (used to set the installation paths):

softwareCode='shaarli'

Set the user and group of the PHP interpreter:

softwareUser='www-data'
softwareGroup='www-data'

Set the installation path:

installPath="/opt/${softwareCode}/${domain}"

Set the data path:

dataPath="/var/lib/${softwareCode}/${domain}"

Set the cache path:

cachePath="/var/cache/${softwareCode}/${domain}"

Create the paths:

${cmdProxy} mkdir --parent "${installPath}" "${dataPath}" "${cachePath}"

Application’s installation

Download the software’s latest stable version:

${cmdProxy} biapy-downloader --forge='github' \
    --output-path="${installPath}" --extract --strip-components=1 \
    --file-template='shaarli-vVERSION-full.tar.gz' 'shaarli/Shaarli' >'/dev/null'

Adjust the files permissions:

${cmdProxy} chown -R root:root "${installPath}"
${cmdProxy} chmod -R go-w "${installPath}"

LSB conformity

Setup a folder structure conform with LSB:

declare -a 'sources' 'destinations'
sources=(); destinations=();
sources+=( 'cache' ); destinations+=( "${cachePath}/cache" );
sources+=( 'pagecache' ); destinations+=( "${cachePath}/pagecache" );
sources+=( 'tmp' ); destinations+=( "${cachePath}/tmp" );
sources+=( 'data' ); destinations+=( "${dataPath}/data" );

Move the folders to the LSB recommended emplacements:

for key in "${!sources[@]}"; do
  if [[ -d "${installPath}/${sources[${key}]}" && ! -e "${destinations[${key}]}" ]]; then
    ${cmdProxy} mv "${installPath}/${sources[${key}]}" "${destinations[${key}]}"
    ${cmdProxy} ln -s "${destinations[${key}]}" "${installPath}/${sources[${key}]}"
    ${cmdProxy} chown -R "${softwareUser}":"${softwareGroup}" "${destinations[${key}]}"
  fi
done

Material theme

Install the latest version of the theme:

${cmdProxy} biapy-downloader --forge='github' \
    --extract --output-path="${installPath}/tpl" \
    --file-template='vVERSION.tar.gz' 'kalvn/Shaarli-Material' >'/dev/null'

Other themes for Shaarli are listed in the Shaarli Theming documentation (en).

Third party plugins

A comprehensive list of third party plugins is available at Shaarly Community & related software (en).

VirtualHost setup

Create the HTTP server configuration for the domain:

if [[ -n "${sslKeyName}" && ( -e "/etc/ssl/private/${sslKeyName}.key" || "${sslKeyName}" = 'auto' ) ]]; then
  ${cmdProxy} a2tools --ssl="${sslKeyName}" --overrides='All' "${domain}" "${installPath}"
else
  ${cmdProxy} a2tools --overrides='All' "${domain}" "${installPath}"
fi

The software is now available on the domain.

Backup

Setup the backup of the installed software:

${cmdProxy} bu-tools --add="${installPath}" --add="${dataPath}"

Automatic updates

Install the updater script :

${cmdProxy} wget --quiet --no-check-certificate \
    --output-document='/usr/local/bin/shaarli-updater' \
    'https://raw.githubusercontent.com/biapy/howto.biapy.com/master/updaters/shaarli-updater'

Declare the downloaded file as executable:

${cmdProxy} chmod +x '/usr/local/bin/shaarli-updater'

Configure biapy-updater automatic updates to check for newer versions of the updater script:

command grep --quiet 'shaarli-updater' '/etc/biapy-updater.conf' \
  || ${cmdProxy} tee -a '/etc/biapy-updater.conf' <<< 'shaarli-updater'

Setup a cron task checking daily for newer versions of the software:

${cmdProxy} tee "/etc/cron.d/${softwareCode}-updater-${domain//./-}" \
  <<< "#
# Regular cron jobs for updating Shaarli at ${domain}
#
# Every night at 5:45.
45 5 * * *   root    PATH=\"\$PATH:/usr/local/bin\"; test -x /usr/local/bin/shaarli-updater && /usr/local/bin/shaarli-updater '${installPath}'"

Reload cron daemon configuration:

${cmdProxy} systemctl 'restart' 'cron'

Thanks


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.