aria2: fix bugs and make some changes 2987/head
authorHsing-Wang Liao <kuoruan@gmail.com>
Sun, 24 Jul 2016 07:56:45 +0000 (15:56 +0800)
committerHsing-Wang Liao <kuoruan@gmail.com>
Sun, 24 Jul 2016 08:02:19 +0000 (16:02 +0800)
* Fix aria2c failed to start after change daemon user, issue #2985;
* Change default download dir;
* Clear exist log file when aria2 start;
* Add log level option;
* Change dir owner when start.

Signed-off-by: Hsing-Wang Liao <kuoruan@gmail.com>
net/aria2/Makefile
net/aria2/files/aria2.conf
net/aria2/files/aria2.init

index 1c70510c62dd0a6788830aeb1cf6f8435f0bac0a..b88e26c71f1b003cc4169d24d1205bdb2fd789af 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=aria2
 PKG_VERSION:=1.25.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://github.com/aria2/aria2/releases/download/release-$(PKG_VERSION)/
index 22aca30cacdb4e68e79d93545d1620afe6708f79..e6d76171fc54f0e38fef2a6a7bb466091ccb52c7 100644 (file)
@@ -6,5 +6,5 @@ config aria2 'main'
        option enable_dht 'true'
        option follow_torrent 'true'
        option user 'root'
-       option dir '/mnt/sda1'
+       option dir '/mnt/sda1/aria2'
        option save_session_interval '30'
index ab5a0e6b034ef86c704027ad9902b54470390d46..d6bcda4ab7fc38a89f4645349ea1711821cb0336 100755 (executable)
@@ -37,6 +37,7 @@ start_instance() {
        section_enabled "$s" || return 1
 
        config_get config_dir "$s" 'config_dir' '/var/etc/aria2'
+       config_get dir "$s" 'dir'
        config_get user "$s" 'user'
 
        config_file="$config_dir/aria2.conf"
@@ -47,25 +48,35 @@ start_instance() {
        [ -d "$config_dir" ] || {
                mkdir -m 0755 -p "$config_dir"
                touch "$config_file"
-               [ -z "$user" ] || chown -R $user $config_dir
        }
 
-       touch "$session_file"
+       [ -d "$dir" ] || {
+               mkdir -m 0755 -p "$dir" # create download dir
+               touch "$dir"
+       }
+
+       touch "$session_file" # create session file
 
        echo -e "enable-rpc=true\nrpc-allow-origin-all=true\nrpc-listen-all=true\nquiet=true" > $config_file
        echo -e "continue=true\ninput-file=$session_file\nsave-session=$session_file" >> $config_file
 
        option_disabled "$s" 'enable_dht' || echo "dht-file-path=$dht_file" >> $config_file
        option_disabled "$s" 'enable_log' || {
-                touch "$log_file"
+               [ -f "$log_file" ] && echo > $log_file # if log file exist, clear it
                 echo -e "log=$log_file" >> $config_file
         }
 
+       # if user is set, change dir owner
+       [ -z "$user" ] || {
+               chown -R $user:$user $config_dir
+               chown -R $user:$user $dir
+       }
+
        append_params "$s" \
                file_allocation bt_enable_lpd enable_dht rpc_user rpc_passwd rpc_listen_port dir bt_tracker disk_cache \
                max_overall_download_limit max_overall_upload_limit max_download_limit max_upload_limit max_concurrent_downloads \
                max_connection_per_server min_split_size split save_session_interval follow_torrent listen_port bt_max_peers \
-               peer_id_prefix user_agent rpc_secret
+               peer_id_prefix user_agent rpc_secret log_level
        
        config_list_foreach "$s" extra_settings append_extrasettings