diff options
author | Zhang Hua | 2024-03-26 20:01:19 +0800 |
---|---|---|
committer | Zhang Hua | 2024-03-26 20:07:43 +0800 |
commit | c532e85c97e1d64f2c1fc424a11cfbf5f677bf3b (patch) | |
tree | 5b566c520faa61e3c3d26925b34dc1de2594e63b /update-aria2-tracker | |
parent | 14e85bad542ef69cb4ba6dabf993a5e039f6a31e (diff) | |
download | aur-c532e85c97e1d64f2c1fc424a11cfbf5f677bf3b.tar.gz |
Misc changes
1. Use Type=simple instead Type=fork
Systemd seems to be happier with this
2. Remove tmpfiles.d and sysusers.d
Use DynamicUser instead
3. Remove hardcoded arguments in service
This should let user have more control
4. Adjust sandbox options in service
5. Move depends in package()
So we do not need install aria2 and systemd
when building
6. Update broken tracker link
But users have to update it manually for
installed files
7. aria2.target now runs after service and timer
Diffstat (limited to 'update-aria2-tracker')
-rw-r--r-- | update-aria2-tracker | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/update-aria2-tracker b/update-aria2-tracker index f48505ce05fc..928cb05ced48 100644 --- a/update-aria2-tracker +++ b/update-aria2-tracker @@ -3,25 +3,43 @@ set -e function get_aria2_home(){ - [[ $(id -nu) == "root" && $1 == "--systemd" ]] && echo /etc/aria2cd && return 0 + if [[ "$1" == "--systemd" ]] + then + echo /etc/aria2cd + return 0 + fi for path in ${HOME}/.aria2 ${XDG_CONFIG_HOME:-${HOME}/.config}/aria2 do - [[ -f ${path}/aria2.conf ]] && echo ${path} && return 0 + if [[ -f ${path}/aria2.conf ]] + then + echo "${path}" + return 0 + fi done - echo ${HOME}/.aria2 && return 0 + echo "${HOME}/.aria2" + return 0 } -ARIA2_CONFIG_HOME=$(get_aria2_home $1) +ARIA2_CONFIG_HOME=$(get_aria2_home "$1") echo "Aria2 config is placing at ${ARIA2_CONFIG_HOME}" if [[ -f "${ARIA2_CONFIG_HOME}/tracker-config.sh" ]] then echo "Loading config from ${ARIA2_CONFIG_HOME}/tracker-config.sh" source "${ARIA2_CONFIG_HOME}/tracker-config.sh" fi -[[ -z $ENABLED ]] && ENABLED=false -$ENABLED || exit 0 -[[ -z $TRACKER ]] && \ - TRACKER=$(curl -Ls https://cdn.staticaly.com/gh/XIU2/TrackersListCollection/master/best_aria2.txt) -grep -q 'bt-tracker=' "${ARIA2_CONFIG_HOME}/aria2.conf" && \ - sed -i "s@bt-tracker=.*@bt-tracker=$TRACKER@" "${ARIA2_CONFIG_HOME}/aria2.conf" || \ - sed -i "\$a bt-tracker=$TRACKER" "${ARIA2_CONFIG_HOME}/aria2.conf" +ENABLED=${ENABLED:-false} +if $ENABLED +then + if [[ -z $TRACKER ]] + then + exit 1 + fi + if grep -q 'bt-tracker=' "${ARIA2_CONFIG_HOME}/aria2.conf" + then + echo "Replacing tracker line" + sed -i "s@bt-tracker=.*@bt-tracker=$TRACKER@" "${ARIA2_CONFIG_HOME}/aria2.conf" + else + echo "Adding tracker line" + sed -i "\$a bt-tracker=$TRACKER" "${ARIA2_CONFIG_HOME}/aria2.conf" + fi +fi |