#!/bin/sh /etc/rc.common START=99 get_config() { config_get_bool enable "$1" enable 0 } config_qbittorrent() { local download_dir local profile_dir local port local socks5_server local socks5_port local socks5_user local socks5_pass config_get download_dir "$1" "download_dir" config_get port "$1" "port" config_get socks5_server "$1" "socks5_server" config_get socks5_port "$1" "socks5_port" config_get socks5_user "$1" "socks5_user" config_get socks5_pass "$1" "socks5_pass" config_get profile_dir "$1" "profile_dir" mkdir -p "$download_dir" mkdir -p "$2" "$2/qBittorrent" "$2/qBittorrent/config" { [ "$2" != "/etc" ] && [ "$2" != "/etc/" ]; } && ln -sf "/etc/qBittorrent/ipfilter.dat" "$2/qBittorrent/ipfilter.dat" if [ -f "$2/qBittorrent/config/qBittorrent.conf" ]; then sed -i 's/WebUI\\Port=[0-9]*/WebUI\\Port='"$port"'/g' "$2/qBittorrent/config/qBittorrent.conf" sed -i "/Downloads\\\SavePath/c\Downloads\\\SavePath=$download_dir" "$2/qBittorrent/config/qBittorrent.conf" sed -i "/Proxy\\\IP/c\Proxy\\\IP=$socks5_server" "$2/qBittorrent/config/qBittorrent.conf" sed -i "/Proxy\\\Port/c\Proxy\\\Port=$socks5_port" "$2/qBittorrent/config/qBittorrent.conf" sed -i "/Proxy\\\Username/c\Proxy\\\Username=$socks5_user" "$2/qBittorrent/config/qBittorrent.conf" sed -i "/Proxy\\\Password/c\Proxy\\\Password=$socks5_pass" "$2/qBittorrent/config/qBittorrent.conf" else cat >"$2/qBittorrent/config/qBittorrent.conf"</dev/null 2>&1 }