### Start Stash Service (FreeBSD service) Source: https://docs.stashapp.cc/installation/truenas_q= This command starts the Stash service manually. It can be used after enabling the service or for immediate startup without rebooting. The service will be accessible at `http://jail-IP:9999/`. ```shell service stash start ``` -------------------------------- ### Run Stash Binary Source: https://docs.stashapp.cc/installation/linux Executes the Stash application binary on Linux. After downloading and potentially making the binary executable, this command starts the Stash server. It typically opens a web interface at http://localhost:9999. ```bash ./ ``` -------------------------------- ### Download and Prepare stash-linux Binary on TrueNAS CORE Source: https://docs.stashapp.cc/installation/truenas_q= Downloads the stash-linux binary from GitHub, sets its ownership to the 'stash' user and group, and makes it executable. This prepares the binary for execution within the jail. ```shell cd /usr/local/bin fetch https://github.com/stashapp/stash/releases/download/v0.22.1/stash-linux chown stash:stash stash-linux chmod +x stash-linux ``` -------------------------------- ### Task Configuration Example (YAML) Source: https://docs.stashapp.cc/in-app-manual/plugins_q= Illustrates the structure for configuring tasks within a plugin. Each task has a name, an optional description, and can define default arguments. ```yaml tasks: - name: description: defaultArgs: argKey: argValue ``` -------------------------------- ### Enable and Start Stash System Service Source: https://docs.stashapp.cc/installation/synology_q= Enables the Stash systemd service to start automatically on boot and then starts the service immediately. This ensures Stash runs in the background and is accessible. ```bash sudo systemctl enable "$(pwd)/stash.service" sudo systemctl start stash.service ``` -------------------------------- ### Enable Stash Service at Boot (FreeBSD sysrc) Source: https://docs.stashapp.cc/installation/truenas_q= This command enables the Stash service to start automatically when the system boots. It uses the `sysrc` utility to set the `stash_enable` variable to `YES` in the system configuration. ```shell sysrc "stash_enable=YES" ``` -------------------------------- ### Create rc.d Startup Script for Stash on TrueNAS CORE Source: https://docs.stashapp.cc/installation/truenas_q= Creates the directory for rc.d startup scripts and begins the creation of the 'stash' service script. This script will allow Stash to run as a daemon and start automatically on boot. ```shell mkdir /usr/local/etc/rc.d ee /usr/local/etc/rc.d/stash ``` -------------------------------- ### Hook Configuration Example (YAML) Source: https://docs.stashapp.cc/in-app-manual/plugins_q= Shows how to configure hooks to trigger plugin operations during Stash events. Hooks can be named, described, specify trigger conditions, and define default arguments. ```yaml hooks: - name: description: triggeredBy: - ... defaultArgs: argKey: argValue ``` -------------------------------- ### Interactive Client Provider Interface and Example Source: https://docs.stashapp.cc/in-app-manual/plugins/uipluginapi_q= Defines interfaces for interactive client providers and demonstrates how to patch the `connect` method for custom logging. This allows developers to hook into the lifecycle of funscripts and interact with devices. ```typescript export interface IDeviceSettings { connectionKey: string; scriptOffset: number; estimatedServerTimeOffset?: number; useStashHostedFunscript?: boolean; [key: string]: unknown; } export interface IInteractiveClientProviderOptions { handyKey: string; scriptOffset: number; defaultClientProvider?: IInteractiveClientProvider; stashConfig?: GQL.ConfigDataFragment; } export interface IInteractiveClientProvider { (options: IInteractiveClientProviderOptions): IInteractiveClient; } /** * Interface that is used for InteractiveProvider */ export interface IInteractiveClient { connect(): Promise; handyKey: string; uploadScript: (funscriptPath: string, apiKey?: string) => Promise; sync(): Promise; configure(config: Partial): Promise; play(position: number): Promise; pause(): Promise; ensurePlaying(position: number): Promise; setLooping(looping: boolean): Promise; readonly connected: boolean; readonly playing: boolean; } // Example of patching the connect method InteractiveUtils.interactiveClientProvider = ( opts ) => { if (!opts.defaultClientProvider) { throw new Error('invalid setup'); } const client = opts.defaultClientProvider(opts); const connect = client.connect; client.connect = async () => { console.log('patching connect method'); return connect.call(client); }; return client; }; ``` -------------------------------- ### Install ffmpeg/ffprobe on TrueNAS CORE Jail Source: https://docs.stashapp.cc/installation/truenas_q= Installs the ffmpeg and ffprobe packages within an iocage jail on TrueNAS CORE. This is a prerequisite for running the stash-linux binary. ```shell pkg install ffmpeg ``` -------------------------------- ### Javascript GQL API Example for Tag Creation Source: https://docs.stashapp.cc/in-app-manual/plugins/embeddedplugins An example of using the `gql.Do` method in Javascript to create a tag via a GraphQL mutation. It includes defining the mutation, variables, executing the query, and logging the result. ```javascript // creates a tag var mutation = "\ mutation tagCreate($input: TagCreateInput!) {\ tagCreate(input: $input) {\ id\ } }"; var variables = { input: { 'name': tagName } }; result = gql.Do(mutation, variables); log.Info("tag id = " + result.tagCreate.id); ``` -------------------------------- ### Install Stash Scraper and Plugin Dependencies Source: https://docs.stashapp.cc/installation/synology_q= Installs Python dependencies for Stash scrapers and plugins using pipreqs. It scans the .stash directory for requirements and installs them into the active environment. ```bash pipreqs .stash/. pip3 install -r .stash/requirements.txt ``` -------------------------------- ### Prepare Python Environment for Stash Source: https://docs.stashapp.cc/installation/synology_q= Sets up a dedicated Python 3.11 virtual environment for Stash scrapers and plugins. It installs pipreqs for dependency management within this environment. ```bash python3.11 -m ensurepip --Update python3.11 -m venv stash-env source stash-env/bin/activate pip3 install pipreqs ``` -------------------------------- ### XPath Scraper Configuration Example Source: https://docs.stashapp.cc/in-app-manual/scraping/scraperdevelopment_q= Demonstrates how to configure an XPath scraper for the 'Name' field of a performer. It shows how to select an element by its tag and attribute. ```yaml performer: Name: //h1[@itemprop="name"] ``` -------------------------------- ### Scene Update Operation Hook Context Example Source: https://docs.stashapp.cc/in-app-manual/plugins_q= Illustrates the 'hookContext' object for a Scene update operation. This example shows the 'type' as 'Scene.Update.Post', the 'id' of the scene, the detailed 'input' object with fields like 'tag_ids' and 'id', and the 'inputFields' array indicating which fields were provided. ```json { "hookContext": { "type":"Scene.Update.Post", "id":45, "input":{ "clientMutationId":null, "id":"45", "title":null, "details":null, "url":null, "date":null, "rating":null, "organized":null, "studio_id":null, "gallery_ids":null, "performer_ids":null, "groups":null, "tag_ids":["21"], "cover_image":null, "stash_ids":null }, "inputFields":[ "tag_ids", "id" ] } } ``` -------------------------------- ### Make Binary Executable Source: https://docs.stashapp.cc/installation/linux Ensures that the downloaded Stash binary file has execute permissions. This is a common troubleshooting step if the binary fails to run directly. It modifies the file's permissions for the owner. ```bash chmod u+x ``` -------------------------------- ### Javascript Plugin Output Examples Source: https://docs.stashapp.cc/in-app-manual/plugins/embeddedplugins Demonstrates three different ways to return output from a Javascript embedded plugin task. The output must conform to the structure defined in the Plugins page. ```javascript (function() { return { Output: "ok" }; })(); ``` ```javascript function main() { return { Output: "ok" }; } main(); ``` ```javascript var output = { Output: "ok" }; output; ``` -------------------------------- ### Configure FFmpeg Input Arguments Source: https://docs.stashapp.cc/in-app-manual/configuration Allows injection of additional arguments before the input file in ffmpeg commands for preview generation, sprite creation, and live transcoding. Arguments are provided as a list of strings. ```text Input: - "-reconnect" - "1" ``` -------------------------------- ### Get Linux Processor Architecture Source: https://docs.stashapp.cc/installation/linux Determines the processor architecture of the Linux system. This is crucial for downloading the correct Stash binary. The output can be used to select the appropriate ``. ```bash uname -p ``` -------------------------------- ### Configure Stash Executable Binary Path (FreeBSD sysrc) Source: https://docs.stashapp.cc/installation/truenas_q= This command allows you to specify a custom path for the Stash executable binary if it's not located in the default path. ```shell sysrc "stash_exec_bin=/path/to/stash-linux" ``` -------------------------------- ### Configure FFmpeg Output Arguments Source: https://docs.stashapp.cc/in-app-manual/configuration Allows injection of additional arguments before the output file in ffmpeg commands for preview generation, sprite creation, and live transcoding. Arguments are provided as a list of strings. ```text Output: - "-c:v libx264" - "-preset:v ultrafast" ``` -------------------------------- ### Enable Linux Compatibility on TrueNAS CORE Source: https://docs.stashapp.cc/installation/truenas_q= Enables Linux compatibility on TrueNAS CORE by setting the 'linux_enable' tunable in the system and configuring it within the iocage jail's rc.conf. ```shell # In TrueNAS Web UI: System -> Tunables -> Add # Variable: linux_enable # Value: YES # Type: rc.conf # In iocage jail /etc/rc.conf: enable_linux="YES" # Reboot the system after applying changes. ``` -------------------------------- ### Link ffprobe and ffmpeg on Synology (Non-Docker) Source: https://docs.stashapp.cc/installation/synology Creates symbolic links for ffprobe and ffmpeg on a Synology NAS to ensure they are accessible in the system's PATH. This is a crucial step for the non-Docker installation of Stash, which relies on these tools for media processing. ```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 ``` -------------------------------- ### Plugin Assets Mapping Example Source: https://docs.stashapp.cc/in-app-manual/plugins_q= Demonstrates how asset URLs are mapped to filesystem paths within a plugin. Relative paths are resolved against the plugin configuration file's directory. Mappings attempting to access files outside the plugin directory are ignored. ```yaml assets: foo: bar /: . ``` -------------------------------- ### Configure Stash User and Group (FreeBSD sysrc) Source: https://docs.stashapp.cc/installation/truenas_q= These commands allow you to change the user and group under which the Stash service runs. It's crucial that the `config_dir` and the `stash-linux` binary are owned by the specified user and group. ```shell sysrc "stash_user=usernamegoeshere" sysrc "stash_group=groupnamegoeshere" ``` -------------------------------- ### Create Stash Configuration Directory on TrueNAS CORE Source: https://docs.stashapp.cc/installation/truenas_q= Creates a directory for Stash's configuration files, database, and other data on TrueNAS CORE. It also sets the ownership of this directory to the 'stash' user and group. ```shell mkdir /usr/local/etc/stash chown stash:stash /usr/local/etc/stash ``` -------------------------------- ### Create stash User and Group on TrueNAS CORE Source: https://docs.stashapp.cc/installation/truenas_q= Creates a dedicated user and group named 'stash' on TrueNAS CORE for running the Stash service. This follows the recommendation to avoid running services as root. ```shell pw useradd -n stash -u 1069 -d /nonexistent -s /usr/sbin/nologin ``` -------------------------------- ### Download Stash Binaries for Synology (Non-Docker) Source: https://docs.stashapp.cc/installation/synology Downloads the appropriate Stash binary for different Synology architectures (x86_64, arm32v6, arm32v7, arm64v8) and its corresponding checksum file. This is part of the manual installation process for Stash when Docker is not used. ```bash # Find what architecture your Synology is running on uname -m # Download the correct version of stash based on architecture # 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 file wget https://github.com/stashapp/stash/releases/latest/download/CHECKSUMS_SHA1 ``` -------------------------------- ### Make Stash rc.d script executable Source: https://docs.stashapp.cc/installation/truenas_q= This command makes the Stash service control script executable, allowing it to be run as a system service. This is a necessary step after placing the script in the appropriate directory (e.g., `/usr/local/etc/rc.d/`). ```shell chmod +x /usr/local/etc/rc.d/stash ``` -------------------------------- ### Configure Stash Configuration Directory (FreeBSD sysrc) Source: https://docs.stashapp.cc/installation/truenas_q= This command allows you to specify a custom directory for Stash configuration files. The path must end with `config.yml`, and Stash will create it if it doesn't exist. Ensure correct ownership and permissions for the chosen location. ```shell sysrc "stash_config_dir=path/to/location/config.yml" ``` -------------------------------- ### PluginApi.utils.InteractiveUtils Source: https://docs.stashapp.cc/in-app-manual/plugins/uipluginapi_q= Provides access to `interactiveClientProvider` and `getPlayer`. `interactiveClientProvider` allows hooking into the lifecycle of funscripts. ```APIDOC ## PluginApi.utils.InteractiveUtils ### Description This namespace provides access to `interactiveClientProvider` and `getPlayer`. `getPlayer` returns the current `videojs` player object. `interactiveClientProvider` takes `IInteractiveClientProvider` which allows a developer to hook into the lifecycle of funscripts. ### Interfaces ```typescript export interface IDeviceSettings { connectionKey: string; scriptOffset: number; estimatedServerTimeOffset?: number; useStashHostedFunscript?: boolean; [key: string]: unknown; } export interface IInteractiveClientProviderOptions { handyKey: string; scriptOffset: number; defaultClientProvider?: IInteractiveClientProvider; stashConfig?: GQL.ConfigDataFragment; } export interface IInteractiveClientProvider { (options: IInteractiveClientProviderOptions): IInteractiveClient; } /** * Interface that is used for InteractiveProvider */ export interface IInteractiveClient { connect(): Promise; handyKey: string; uploadScript: (funscriptPath: string, apiKey?: string) => Promise; sync(): Promise; configure(config: Partial): Promise; play(position: number): Promise; pause(): Promise; ensurePlaying(position: number): Promise; setLooping(looping: boolean): Promise; readonly connected: boolean; readonly playing: boolean; } ``` ### Example ```javascript InteractiveUtils.interactiveClientProvider = ( opts ) => { if (!opts.defaultClientProvider) { throw new Error('invalid setup'); } const client = opts.defaultClientProvider(opts); const connect = client.connect; client.connect = async () => { console.log('patching connect method'); return connect.call(client); }; return client; }; ``` ``` -------------------------------- ### Stash Service Control Script (FreeBSD rc.d) Source: https://docs.stashapp.cc/installation/truenas_q= This script manages the Stash service on FreeBSD systems. It defines variables for the service name, enable status, user, group, configuration directory, and executable binary. It also sets up the daemonization process and pre-start commands to ensure necessary files exist. ```shell . /etc/rc.subr name=stash rcvar=stash_enable load_rc_config $name : ${stash_enable:="NO"} : ${stash_user:="stash"} : ${stash_group:="stash"} : ${stash_config_dir:="/usr/local/etc/stash/config.yml"} : ${stash_exec_bin:="/usr/local/bin/stash-linux"} #daemon pidfile="/var/run/${name}.pid" command="/usr/sbin/daemon" command_args="-f -P ${pidfile} ${stash_exec_bin} --config ${stash_config_dir}" start_precmd="stash_precmd" stash_precmd() { install -o ${stash_user} -g ${stash_group} /dev/null ${pidfile} } run_rc_command $1 ``` -------------------------------- ### Configure NAS Profile for Stash Environment Source: https://docs.stashapp.cc/installation/synology_q= Creates and configures a .profile file on a NAS to ensure the Stash environment is activated and the PATH is set correctly on login. This is crucial for running Stash and its associated scripts. ```bash echo 'PATH=/usr/local/bin:$PATH' > .profile echo 'source stash-env/bin/activate' >> .profile ```