Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

脚本有问题 #13

Closed
zlx42 opened this issue Dec 7, 2019 · 9 comments
Closed

脚本有问题 #13

zlx42 opened this issue Dec 7, 2019 · 9 comments

Comments

@zlx42
Copy link

zlx42 commented Dec 7, 2019

我在群晖里装的,脚本判断有问题,好像没把path里的扩展名去掉,导致出错
path=${path%%.*}之类的?

@SuperNG6
Copy link
Owner

SuperNG6 commented Dec 8, 2019

我觉得没有问题吧,如果无法执行,大概是因为权限问题,readme里的文档有写

#!/bin/bash

downloadpath='/downloads'

filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
    then
        exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
    then
    [ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2
    exit 0
elif [ "$path" != "$filepath" ] && [ $2 -gt 1 ]
    then
    [ -e "$path".aria2 ] && rm -vf "$path".aria2
    exit 0
elif [ "$path" != "$filepath" ] && [ $2 -eq 1 ]
    then
    [ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2
    exit 0
fi

@zlx42
Copy link
Author

zlx42 commented Feb 21, 2020

新版本好像还是不行,我改成这样就可以

#!/bin/bash

downloadpath='/downloads'
filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
    then
        exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
    then
    path2=${path%.*}
    [ -e "$path2".aria2 ] && rm -f "$path2".aria2 
    exit 0
elif [ "$path" != "$filepath" ] && [ $2 -gt 1 ]
    then
    path3=${path%.*}
    [ -e "$path3".aria2 ] && rm -f "$path3".aria2
    exit 0
elif [ "$path" != "$filepath" ] && [ $2 -eq 1 ]
    then
    path4=${path%.*}
    [ -e "$path4".aria2 ] && rm -f "$path4".aria2
    exit 0
fi

@SuperNG6
Copy link
Owner

今天抽时间研究了一下aria2的参数传递,更新了删除文件的脚本,经过测试删除功能正常运行,删除功能已完善

@zlx42
Copy link
Author

zlx42 commented Feb 26, 2020

我在群晖里面还是不行,$3是带有扩展名的~你的这个删除时有扩展名就出错

@SuperNG6
Copy link
Owner

SuperNG6 commented Feb 26, 2020 via email

@SuperNG6
Copy link
Owner

SuperNG6 commented Feb 26, 2020

我的建议是你删除容器,重新建一个,脚本估计是因为你修改过所以没被替换
你可以进容器 cat /aria2/script/delete.sh 看一下是否是新的脚本

@zlx42
Copy link
Author

zlx42 commented Feb 26, 2020

容器更新过了,我容器看过了,是最新的脚本。
后来不行,我自定义的脚本也换成你的最新版了。结果还是不行

我用echo [$(date)] $filepath "
" >> /config/_log.html输出记录的是
/downloads/abcd/abcd.mp4之类的,

[Wed Feb 26 19:19:33 CST 2020] m1 , /downloads/trackers_all.txt

[Wed Feb 26 20:59:41 CST 2020] m3 , /downloads/abcd.mp4

但是.aria2文件是/downloads/abcd.aria2
感觉应该是你的filepath直接用的$3,是带扩展名的,你的脚本目前只有dirpath是正确的,其他的只要用[ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2都会变成/downloads/abcd/abcd.mp4.aria2这样的就删除失败了。。。。

#!/bin/bash

downloadpath='/downloads'

filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/}
dirpath=${filepath%/
}

if [ $2 -eq 0 ]
then
exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
[ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2
echo [$(date)] m1 , $filepath "
" >> /config/_log.html

exit 0
elif [ "$path" != "$filepath" ] && [ $2 -gt 1 ]
then
[ -e "$dirpath".aria2 ] && rm -vf "$dirpath".aria2
echo [$(date)] m2 , $dirpath "
" >> /config/_log.html

exit 0
elif [ "$path" != "$filepath" ] && [ $2 -eq 1 ]
then
[ -e "$dirpath".aria2 ] && rm -vf "$filepath".aria2
echo [$(date)] m1 ,$dirpath "
" >> /config/_log.html
exit 0

@SuperNG6
Copy link
Owner

SuperNG6 commented Feb 26, 2020 via email

@zlx42
Copy link
Author

zlx42 commented Feb 26, 2020

都说了按输出的记录显示filepath内容使用扩展名的,你用dirpath之类的都是对的,但是用filepath输出的都带扩展名。

[Wed Feb 26 19:19:33 CST 2020] m1 , /downloads/trackers_all.txt

"$filepath" 的内容是 /downloads/abcd.mp4 ,所以命令输出就会变成/downloads/abcd.mp4.aria2
是不是DSM6.22这个群晖系统有问题??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants