luci-app-qbittorrent: fix init

This commit is contained in:
CN_SZTL 2020-01-28 16:27:17 +08:00
parent 5906fcecde
commit f869b8cab8
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -12,12 +12,15 @@ config_qbittorrent()
local port
config_get download_dir $1 download_dir
config_get port $1 port
mkdir -p $download_dir
mkdir -p $2
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 's/Downloads\\SavePath=[a-z,/]*//g' $2/qBittorrent/config/qBittorrent.conf
echo "Downloads\SavePath=$down" >> $2/qBittorrent/config/qBittorrent.conf
sed -i 's/WebUI\\Port=[0-9]*/WebUI\\Port='"$port"'/g' $2/qBittorrent/config/qBittorrent.conf
sed -i 's/Downloads\\SavePath=[a-z,/]*//g' $2/qBittorrent/config/qBittorrent.conf
echo "Downloads\SavePath=$download_dir" >> $2/qBittorrent/config/qBittorrent.conf
else
cat>$2/qBittorrent/config/qBittorrent.conf<<EOF
cat >$2/qBittorrent/config/qBittorrent.conf<<-EOF
[AutoRun]
enabled=false
program=
@ -34,22 +37,20 @@ Downloads\SavePath=$download_dir
General\Locale=zh
WebUI\Port=$port
WebUI\CSRFProtection=false
EOF
EOF
fi
}
run_qbittorrent()
{
local enable
config_get_bool enable $1 enable
if [ $enable ]; then
local profile_dir
config_get profile_dir $1 profile_dir
config_foreach config_qbittorrent 'Preferences' $profile_dir
if [ "$profile_dir" != "" ]; then
mkdir -p $profile_dir/qBittorrent
ln -sf /etc/qBittorrent/ipfilter.dat $profile_dir/qBittorrent/ipfilter.dat
qbittorrent-nox -d --profile=$profile_dir
else
echo "no profile_dir,stop!"
@ -62,7 +63,7 @@ start()
{
stop
local profile_path
config_load 'qbittorrent'
config_load 'qbittorrent'
config_foreach get_config basic
[ $enable -eq 0 ] && exit 0
config_foreach run_qbittorrent 'basic'
@ -70,6 +71,6 @@ start()
stop()
{
killall qbittorrent-nox >/dev/null 2>&1
killall qbittorrent-nox >/dev/null 2>&1
return 0
}