utils/morty.sh

To simplify installation and maintenance of a morty instance you can use the script Origin: utils/morty.sh. In most cases you will install morty simply by running the command:

sudo -H ./utils/morty.sh install all

The script adds a ${SERVICE_USER} (default:morty) and installs morty into this user account:

  1. Create a separated user account (morty).

  2. Download and install Go binary in user’s $HOME (~morty).

  3. Install morty with the package management from Go (go get -v -u github.com/asciimoo/morty)

  4. Setup a systemd service unit [ref] (/lib/systemd/system/morty.service).

Hint

To add morty to your searx instance read chapter How to setup result proxy.

Create user

$ sudo -H useradd --shell /bin/bash --system \
    --home-dir "/usr/local/morty" \
    --comment "Privacy-respecting metasearch engine" morty

$ sudo -H mkdir "/usr/local/morty"
$ sudo -H chown -R "morty:morty" "/usr/local/morty"

Install go

$ cat > "/usr/local/morty/.go_env" <<EOF
export GOPATH=/usr/local/morty/go-apps
export PATH=$PATH:/usr/local/morty/local/go/bin:$GOPATH/bin
EOF
$ sudo -i -u "morty"
(morty) $ echo 'source /usr/local/morty/.go_env' >> ~/.profile
(morty) $ mkdir /usr/local/morty/local
(morty) $ wget --progress=bar -O "go1.13.5.linux-amd64.tar.gz" \
            "https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz"
(morty) $ tar -C /usr/local/morty/local -xzf "go1.13.5.linux-amd64.tar.gz"
(morty) $ which go
/usr/local/morty/local/go/bin/go

Install morty

Install morty software and systemd unit:

$ sudo -i -u "morty"
(morty) $ go get -v -u github.com/asciimoo/morty
[Unit]

Description=morty
After=syslog.target
After=network.target

[Service]

Type=simple
User=morty
Group=morty
WorkingDirectory=/usr/local/morty
ExecStart=/usr/local/morty/go-apps/bin/morty -key '' -listen '127.0.0.1:3000' -timeout 5

Restart=always
Environment=USER=morty HOME=/usr/local/morty DEBUG=false

# Some distributions may not support these hardening directives.  If you cannot
# start the service due to an unknown option, comment out the ones not supported
# by your version of systemd.

ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true

[Install]

WantedBy=multi-user.target

Overview

The --help output of the script is largely self-explanatory (Common commands & environment):

usage::
  morty.sh shell
  morty.sh install    [all|user]
  morty.sh update     [morty]
  morty.sh remove     [all]
  morty.sh activate   [service]
  morty.sh deactivate [service]
  morty.sh inspect    [service]
  morty.sh option     [debug-on|debug-off|new-key]
  morty.sh apache     [install|remove]
  morty.sh nginx      [install|remove]
  morty.sh info       [searx]

shell
  start interactive shell from user morty
install / remove
  all:        complete setup of morty service
  user:       add/remove service user 'morty' (/usr/local/morty)
update morty
  Update morty installation (/usr/local/morty)
activate service
  activate and start service daemon (systemd unit)
deactivate service
  stop and deactivate service daemon (systemd unit)
inspect service
  show service status and log
option
  set one of the available options
  :new-key:   set new morty key
apache : http://fv-az163-121/morty/
  :install: apache site with a reverse proxy (ProxyPass)
  :remove:  apache site morty.conf
nginx (http://fv-az163-121/morty/)
  :install: nginx site with a reverse proxy (ProxyPass)
  :remove:  nginx site morty.conf

If needed, set the environment variables in the '.config.sh' file::
  PUBLIC_URL_MORTY:     http://fv-az163-121/morty/
  MORTY_LISTEN:         127.0.0.1:3000
  SERVICE_USER:         morty

To activate result and image proxy in searx, edit settings.yml (read:
https://searx.github.io/searx/admin/morty.html)::
  result_proxy:
      url : http://fv-az163-121/morty/
  server:
      image_proxy : True