Skip to content

Commit

Permalink
Improved and updated Synology installation (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: DogmaDragon <103123951+DogmaDragon@users.noreply.github.com>
  • Loading branch information
Muldec and DogmaDragon authored Sep 3, 2024
1 parent 37caa54 commit 30e5bab
Showing 1 changed file with 117 additions and 117 deletions.
234 changes: 117 additions & 117 deletions getting-started/installation/synology.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,200 +21,200 @@ Synology devices comes in two categories : those who support containerization th

Now, follow the installation instructions based on whether you [can use Docker](#to-install-stash-with-docker) or [you cannot use Docker](#to-install-stash-without-docker).

# To install Stash with Docker
{: .note }
Running stash without docker is possible even if your NAS is docker ready. It offers more control on your stash instance startup. As an example, it allows you to store your porn collection in an Encrypted Shared Folder, and only run stash when the Encrypted folder is Mounted (Decrypted).

## To install Stash with Docker

- Make sure [the Docker app is installed](https://blog.pavelsklenar.com/how-to-install-and-use-docker-on-synology/){:target="_blank"} and running correctly.
- [Search the registry for stash](https://hub.docker.com/r/stashapp/stash){:target="_blank"} and install.
- Create a stash image with the following set up in 'advanced options'

## "Volume" Tab
### "Volume" Tab

| File/Folder | Mount Path | Description |
|---|---|---|
| docker/Stash/generated | /generated | Thumbnails, clips, etc |
| docker/Stash/metadata | /metadata | Database |
| docker/Stash/config | /root/.stash | Configuration Files |
| docker/Stash/cache | /cache | Cache Files |
| docker/Stash/blobs | /blobs | Binary data for scene covers, performer images, etc |
| (where your porn lives) | /data | Location of your porn |
| File/Folder | Mount Path | Description |
|-------------------------|--------------|-----------------------------------------------------|
| docker/Stash/generated | /generated | Thumbnails, clips, etc |
| docker/Stash/metadata | /metadata | Database |
| docker/Stash/config | /root/.stash | Configuration Files |
| docker/Stash/cache | /cache | Cache Files |
| docker/Stash/blobs | /blobs | Binary data for scene covers, performer images, etc |
| (where your porn lives) | /data | Location of your porn |

## "Environment" Tab
### "Environment" Tab

(These will need to be the same as the Volumes you created in the "Volume" tab.
(These will need to be the same as the Volumes you created in the "Volume" tab.)

| variable | Value |
|---|---|
| PATH | (keep as is) |
| STASH_CACHE | /cache |
| STASH_METADATA | /metadata |
| STASH_GENERATED | /generated |
| STASH_STASH | /data |
| variable | Value |
|-----------------|--------------|
| PATH | (keep as is) |
| STASH_CACHE | /cache |
| STASH_METADATA | /metadata |
| STASH_GENERATED | /generated |
| STASH_STASH | /data |
| | | |

## "Port" Tab
### "Port" Tab

You will need to set a default port in the "Port" tab, otherwise Docker will assign a different port every time Stash is launched. Leave the container port as-is.

## "Network" Tab
### "Network" Tab

Make sure that "Use The Same Network As Docker Host" is checked.

(thanks to backer Herelam80 for these instructions)

# To install Stash without Docker
## To install Stash without Docker

Warning : this method uses SSH to run command lines on the NAS. If you are unfamiliar with SSH or linux command lines, I suggest you not to go further, as making a mistake in the SSH session can really screw your NAS.

This is intended to work on DSM 7.0 and later. It will not work on any version prior to 7.0.

## Enable SSH
### Install Prerequisites

In DSM, navigate to `Control Panel > Terminal & SNMP` and check the `enable SSH service` box.
In DSM, navigate to `Package Center > Settings`. In the `Package Sources` tab, click `Add`, type _SynoCommunity_ as Name and [https://packages.synocommunity.com/](https://packages.synocommunity.com/){:target="_blank"} as Location and then press `OK` to validate.

_Note : only members of the adminstrator group are able to use SSH, you'll need one of them to complete the installation._
Go back to the Package Center and look for `Python 3.11` in the Community tab. Click on `Ìnstall` and agree to the _Third-Party Package_ warning.

## Create a user that will run stash
Then look for `Ffmpeg 6` in the Community tab. Click on `Ìnstall` and agree to the _Third-Party Package_ warning.

1. In DSM, navigate to `Control Panel > User & Group`
2. Click on the `Create` button
3. Give it a name (eg _stash_) and Generate a Random Password (you won't need it later)
4. Click `Next` until you are on the "Assign shared folders permissions" screen
5. Assign the read write permission to your porn folder (the write permission is needed to allow the deletion of clips from the stash app)
6. Click `Next` until you are on the "Assign application permissions" screen
7. Check `Deny` for all applications
6. Click `Next` until you can click on `Done`
### Enable SSH

## Connect to your NAS
In DSM, navigate to `Control Panel > Connectivity > Terminal & SNMP` and check the `Enable SSH service` box.

With your terminal, connect to your NAS using an account that is part of the _administrator_ group.
### Create a user that will run stash

1. SSH to your NAS
1. In DSM, navigate to `Control Panel > File Sharing > User & Group`
1. Click on the `Create` button
1. Give it a name (eg _stash_) and a Password (you will need it later)
1. Click `Next` until you are on the "Join groups" screen
1. Assign the user to the "administrators" group (this will be removed later but is required by synology to be able to use SSH (I know, it's stupid) and complete the installation properly)
1. Click `Next` until you are on the "Assign shared folders permissions" screen
1. Assign the Read/Write permission to your porn folder (the write permission is needed to allow the deletion of clips from the stash app)
1. Click `Next` until you are on the "Assign application permissions" screen
1. Check `Deny` for all applications
1. Click `Next` until you can click on `Done`

```
ssh admin@nas-hostname
```
### Connect to your NAS

{:style="counter-reset:none"}
2. navigate to the _stash_ user home directory
With your terminal, connect to your NAS using the newly created account that is part of the _administrators_ group.

```
cd ../stash/
```bash
ssh stash@your_nas_hostname
```

## Download Stash
### Link ffprobe & ffmpeg

{:style="counter-reset:none"}
3. Download the lastest ARM64 version of stash and its checksum from github
ffmpeg has been installed earlier, but is missing a link to ffprobe (also installed) and the new version of ffmpeg. Run the following command.

```
wget https://github.com/stashapp/stash/releases/download/[version]/stash-linux-arm64v8
wget https://github.com/stashapp/stash/releases/download/[version]/CHECKSUMS_SHA1
```bash
sudo ln -s /var/packages/ffmpeg6/target/bin/ffprobe /usr/local/bin/ffprobe
sudo ln -s /var/packages/ffmpeg6/target/bin/ffmpeg /usr/local/bin/ffmpeg
```

{:style="counter-reset:none"}
4. Perform the checksum validation
### Download Stash

```
sha1sum -c --ignore-missing CHECKSUMS_SHA1
Download the lastest version of stash and its checksum from github

# you should see a line that says `stash-linux-arm64v8: OK`
```
```bash
# find what architecture your synology is running on
uname -m

{:style="counter-reset:none"}
5. Clean up unnecessary file
# depending on the architecture, you'll have to download the right version of stash

```
rm CHECKSUMS_SHA1
```
# x86_64
wget https://github.com/stashapp/stash/releases/latest/download/stash-linux
# armv6l
wget https://github.com/stashapp/stash/releases/latest/download/stash-linux-arm32v6
# armv7l
wget https://github.com/stashapp/stash/releases/latest/download/stash-linux-arm32v7
# aarch64
wget https://github.com/stashapp/stash/releases/latest/download/stash-linux-arm64v8

_Note : DO NOT run stash yet or it will generated a bunch of files/folders where we don't want them_
# Download the CHECKSUM
wget https://github.com/stashapp/stash/releases/latest/download/CHECKSUMS_SHA1

## Download ffmpeg

{:style="counter-reset:none"}
6. Donwload the ARM64 static build of ffmpeg and its checksum

```
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz.md5
```

{:style="counter-reset:none"}
7. Perform the checksum validation

```
md5sum -c ffmpeg-release-arm64-static.tar.xz.md5
# you should see a line that says `ffmpeg-release-arm64-static.tar.xz: OK`
```
# Perform the checksum validation
sha1sum -c --ignore-missing CHECKSUMS_SHA1

{:style="counter-reset:none"}
8. Unpack & move ffmpeg to the .stash/ folder
# you should see a line that says `stash-linux: OK`
# if not, something went wrong during the download

```
tar xvf ffmpeg-release-arm64-static.tar.xz
mv ffmpeg-4.4-arm64-static/ffmpeg ffmpeg-4.4-arm64-static/ffprobe .stash/
# Clean up the now unnecessary file
rm CHECKSUMS_SHA1
```

{:style="counter-reset:none"}
9. Clean up unnecessary files
{: .note }
DO NOT run stash yet or it will generate a bunch of files/folders where we don't want them_

```
rm ffmpeg-release-arm64-static.tar.xz
rm ffmpeg-release-arm64-static.tar.xz.md5
rm -rd ffmpeg-4.4-arm64-static/
```
### Python

{:style="counter-reset:none"}
10. Prepare a python environment (for scrapers)
Prepare a python environment (for scrapers and plugins)

```
sudo -H python -m ensurepip --upgrade
python3 -m venv stash-env
```bash
python3.11 -m ensurepip --upgrade
python3.11 -m venv stash-env
source stash-env/bin/activate
pip3 install pipreqs
```

Whenever you install a new scraper, do the following from the _stash_ user home directory
### Configure your NAS to run Stash

```
source stash-env/bin/activate
cd your_scraper_directory
pipreqs .
sudo pip3 install -r requirements.txt
```
Create a profile file

## Configure your NAS to run Stash upon startup
```bash
echo 'PATH=/usr/local/bin:$PATH' > .profile
echo 'source stash-env/bin/activate' >> .profile
```

{:style="counter-reset:none"}
10. Create the service file by running `cat > /etc/systemd/system/stash.service`, copy/pasting the following, and hitting CTRL+D when it's done to save the file (hit again if you are not back to the prompt) :
Create the service file by running `cat > stash.service`, copy/pasting the following, and hitting CTRL+D when it's done to save the file (hit again if you are not back to the prompt) :

```
```ini
[Unit]
Description=Run Stash at startup
After=network.target

[Service]
WorkingDirectory=/var/services/homes/stash
Type=simple
User=stash
ExecStart=/bin/bash -c '\
source /var/services/homes/stash/stash-env/bin/activate stash-env; \
exec /var/services/homes/stash/stash-linux-arm64v8'
ExecStart=/bin/bash -c -l '\
exec ./stash-linux'
Restart=on-failure

[Install]
WantedBy=multi-user.target
# end
```

{:style="counter-reset:none"}
11. Start and activate the service
{: .note }
Change the `ExecStart` line by providing the exact name of the stash executable that you downloaded previously.

```
Start and activate the service

```bash
sudo systemctl enable "$(pwd)/stash.service"
sudo systemctl start stash.service
sudo systemctl enable stash.service
```

## Verify that it is working
### Verify that it is working

You can now access to stash by navigating to your NAS url on port 9999 : `http://nas-hostname:9999`

### Installing Scrapers and Plugins

Whenever you install a new python scraper or plugin, do the following from the _stash_ user home directory

```bash
pipreqs .stash/.
pip3 install -r .stash/requirements.txt
```

{: .note }
Using pipreqs allows to scan all scrapers and plugins installed and find dependencies that they require. You can do the same thing without pipreqs by going into each individual directory and run `pip3 install -r requirements.txt`

### Remove stash user from administrator group

1. Go back to DSM, navigate to `Control Panel > File Sharing > User & Group`
1. Click on the _stash_ user and then on `Edit`
1. In the `User Groups` tab, uncheck "administrators" and click on `Save`

0 comments on commit 30e5bab

Please sign in to comment.