Synology
Info
Written by Muldec.
Foreword¶
Synology devices comes in two categories : those who support containerization through Docker, and those who don't. To see in which category you stand, refer to the "Applied Models" section of the Docker Package page.
Now, follow the installation instructions based on whether you can use Docker or you cannot use 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).
- Make sure the Docker app is installed and running correctly.
- Search the registry for stash and install.
- Create a stash image with the following set up in 'advanced options'
"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 |
"Environment" 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 |
"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¶
Make sure that "Use The Same Network As Docker Host" is checked.
(thanks to backer Herelam80 for these instructions)
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.
Install Prerequisites¶
In DSM, navigate to Package Center > Settings
. In the Package Sources
tab, click Add
, type SynoCommunity as Name and https://packages.synocommunity.com/ as Location and then press OK
to validate.
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.
Then look for Ffmpeg 6
in the Community tab. Click on Ìnstall
and agree to the Third-Party Package warning.
Enable SSH¶
In DSM, navigate to Control Panel > Connectivity > Terminal & SNMP
and check the Enable SSH service
box.
Create a user that will run stash¶
- In DSM, navigate to
Control Panel > File Sharing > User & Group
- Click on the
Create
button - Give it a name (eg stash) and a Password (you will need it later)
- Click
Next
until you are on the "Join groups" screen - 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)
- Click
Next
until you are on the "Assign shared folders permissions" screen - Assign the Read/Write permission to your porn folder (the write permission is needed to allow the deletion of clips from the stash app)
- Click
Next
until you are on the "Assign application permissions" screen - Check
Deny
for all applications - Click
Next
until you can click onDone
Connect to your NAS¶
With your terminal, connect to your NAS using the newly created account that is part of the administrators group.
ssh stash@your_nas_hostname
Link ffprobe & ffmpeg¶
ffmpeg has been installed earlier, but is missing a link to ffprobe (also installed) and the new version of ffmpeg. Run the following command.
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
Download Stash¶
Download the lastest version of Stash and its checksum from GitHub
# find what architecture your synology is running on
uname -m
# depending on the architecture, you'll have to download the right version of stash
# 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
# Download the CHECKSUM
wget https://github.com/stashapp/stash/releases/latest/download/CHECKSUMS_SHA1
# Perform the checksum validation
sha1sum -c --ignore-missing CHECKSUMS_SHA1
# you should see a line that says `stash-linux: OK`
# if not, something went wrong during the download
# Clean up the now unnecessary file
rm CHECKSUMS_SHA1
Danger
DO NOT run stash yet or it will generate a bunch of files/folders where we don't want them.
Python¶
Prepare a python environment (for scrapers and plugins)
python3.11 -m ensurepip --Update
python3.11 -m venv stash-env
source stash-env/bin/activate
pip3 install pipreqs
Configure your NAS to run Stash¶
Create a profile file
echo 'PATH=/usr/local/bin:$PATH' > .profile
echo 'source stash-env/bin/activate' >> .profile
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) :
[Unit]
Description=Run Stash at startup
After=network.target
[Service]
WorkingDirectory=/var/services/homes/stash
Type=simple
User=stash
ExecStart=/bin/bash -c -l '\
exec ./stash-linux'
Restart=on-failure
[Install]
WantedBy=multi-user.target
Note
Change the ExecStart
line by providing the exact name of the stash executable that you downloaded previously.
Start and activate the service
sudo systemctl enable "$(pwd)/stash.service"
sudo systemctl start stash.service
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
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¶
- Go back to DSM, navigate to
Control Panel > File Sharing > User & Group
- Click on the stash user and then on
Edit
- In the
User Groups
tab, uncheck "administrators" and click onSave