From 3bff6d82df9cb763c96f8e2261a86d8c42cbc0dd Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 5 Mar 2020 08:58:50 -0500 Subject: [PATCH] Update 02-script-setup.bash --- root/etc/cont-init.d/02-script-setup.bash | 136 +++++++++++++--------- 1 file changed, 80 insertions(+), 56 deletions(-) diff --git a/root/etc/cont-init.d/02-script-setup.bash b/root/etc/cont-init.d/02-script-setup.bash index ec65c47..70f985a 100644 --- a/root/etc/cont-init.d/02-script-setup.bash +++ b/root/etc/cont-init.d/02-script-setup.bash @@ -3,9 +3,10 @@ # Create scripts directory if [ ! -d "/config/scripts" ]; then mkdir -p "/config/scripts" + chmod 0777 "/config/scripts" fi -# Remove existing LAD start script +# Remove existing AudioPostProcessing script if [ -f "/config/scripts/AudioPostProcessing.bash" ]; then rm "/config/scripts/AudioPostProcessing.bash" sleep 0.1 @@ -29,68 +30,91 @@ if [ ! -d "/downloads/complete" ]; then chmod 0777 "/downloads/incomplete" fi -if [ -f "/config/sabnzbd.ini" ]; then +if [ ! -f "/config/scripts/sab-config-updated" ]; then + # start cron + service cron start - if cat "/config/sabnzbd.ini" | grep "/config/scripts" | read; then - sleep 0.1 - else - sed -i "s/script_dir = \"\"/script_dir = \"\/config\/scripts\"/g" "/config/sabnzbd.ini" - fi + if [ -f "/config/sabnzbd.ini" ]; then + + # Add scripts path + if cat "/config/sabnzbd.ini" | grep "/config/scripts" | read; then + sleep 0.1 + else + sed -i "s/script_dir = \"\"/script_dir = \"\/config\/scripts\"/g" "/config/sabnzbd.ini" + fi - if cat "/config/sabnzbd.ini" | grep "/downloads/incomplete" | read; then - sleep 0.1 - else - sed -i "s/Downloads\/incomplete/\/downloads\/incomplete/g" "/config/sabnzbd.ini" - fi + # Correct incomplete path + if cat "/config/sabnzbd.ini" | grep "/downloads/incomplete" | read; then + sleep 0.1 + else + sed -i "s/Downloads\/incomplete/\/downloads\/incomplete/g" "/config/sabnzbd.ini" + fi - if cat "/config/sabnzbd.ini" | grep "/downloads/complete" | read; then - sleep 0.1 - else - sed -i "s/Downloads\/complete/\/downloads\/complete/g" "/config/sabnzbd.ini" - fi + # Correct complete path + if cat "/config/sabnzbd.ini" | grep "/downloads/complete" | read; then + sleep 0.1 + else + sed -i "s/Downloads\/complete/\/downloads\/complete/g" "/config/sabnzbd.ini" + fi - if cat "/config/sabnzbd.ini" | grep "\[\[radarr\]\]" | read; then - sleep 0.1 - else - sed -i '/\[\[movies\]\]/,+7d' "/config/sabnzbd.ini" - echo "[[radarr]]" >> "/config/sabnzbd.ini" - echo "priority = -100" >> "/config/sabnzbd.ini" - echo "pp = \"\"" >> "/config/sabnzbd.ini" - echo "name = radarr" >> "/config/sabnzbd.ini" - echo "script = Default" >> "/config/sabnzbd.ini" - echo "newzbin = \"\"" >> "/config/sabnzbd.ini" - echo "order = 1" >> "/config/sabnzbd.ini" - echo "dir = radarr" >> "/config/sabnzbd.ini" - fi + # Enable script failure + if cat "/config/sabnzbd.ini" | grep "script_can_fail = 0" | read; then + sleep 0.1 + else + sed -i "s/script_can_fail = 0/script_can_fail = 1/g" "/config/sabnzbd.ini" + fi - if cat "/config/sabnzbd.ini" | grep "\[\[sonarr\]\]" | read; then - sleep 0.1 - else - sed -i '/\[\[tv\]\]/,+7d' "/config/sabnzbd.ini" - echo "[[sonarr]]" >> "/config/sabnzbd.ini" - echo "priority = -100" >> "/config/sabnzbd.ini" - echo "pp = \"\"" >> "/config/sabnzbd.ini" - echo "name = sonarr" >> "/config/sabnzbd.ini" - echo "script = Default" >> "/config/sabnzbd.ini" - echo "newzbin = \"\"" >> "/config/sabnzbd.ini" - echo "order = 2" >> "/config/sabnzbd.ini" - echo "dir = sonarr" >> "/config/sabnzbd.ini" - fi + # Add radarr category + if cat "/config/sabnzbd.ini" | grep "\[\[radarr\]\]" | read; then + sleep 0.1 + else + sed -i '/\[\[movies\]\]/,+7d' "/config/sabnzbd.ini" + echo "[[radarr]]" >> "/config/sabnzbd.ini" + echo "priority = -100" >> "/config/sabnzbd.ini" + echo "pp = \"\"" >> "/config/sabnzbd.ini" + echo "name = radarr" >> "/config/sabnzbd.ini" + echo "script = Default" >> "/config/sabnzbd.ini" + echo "newzbin = \"\"" >> "/config/sabnzbd.ini" + echo "order = 1" >> "/config/sabnzbd.ini" + echo "dir = radarr" >> "/config/sabnzbd.ini" + fi + + # Add sonarr category + if cat "/config/sabnzbd.ini" | grep "\[\[sonarr\]\]" | read; then + sleep 0.1 + else + sed -i '/\[\[tv\]\]/,+7d' "/config/sabnzbd.ini" + echo "[[sonarr]]" >> "/config/sabnzbd.ini" + echo "priority = -100" >> "/config/sabnzbd.ini" + echo "pp = \"\"" >> "/config/sabnzbd.ini" + echo "name = sonarr" >> "/config/sabnzbd.ini" + echo "script = Default" >> "/config/sabnzbd.ini" + echo "newzbin = \"\"" >> "/config/sabnzbd.ini" + echo "order = 2" >> "/config/sabnzbd.ini" + echo "dir = sonarr" >> "/config/sabnzbd.ini" + fi - if cat "/config/sabnzbd.ini" | grep "\[\[lidarr\]\]" | read; then - sleep 0.1 - else - sed -i '/\[\[audio\]\]/,+7d' "/config/sabnzbd.ini" - echo "[[lidarr]]" >> "/config/sabnzbd.ini" - echo "priority = -100" >> "/config/sabnzbd.ini" - echo "pp = \"\"" >> "/config/sabnzbd.ini" - echo "name = lidarr" >> "/config/sabnzbd.ini" - echo "script = AudioPostProcessing.bash" >> "/config/sabnzbd.ini" - echo "newzbin = \"\"" >> "/config/sabnzbd.ini" - echo "order = 3" >> "/config/sabnzbd.ini" - echo "dir = lidarr" >> "/config/sabnzbd.ini" + # Add lidarr category + if cat "/config/sabnzbd.ini" | grep "\[\[lidarr\]\]" | read; then + sleep 0.1 + else + sed -i '/\[\[audio\]\]/,+7d' "/config/sabnzbd.ini" + echo "[[lidarr]]" >> "/config/sabnzbd.ini" + echo "priority = -100" >> "/config/sabnzbd.ini" + echo "pp = \"\"" >> "/config/sabnzbd.ini" + echo "name = lidarr" >> "/config/sabnzbd.ini" + echo "script = AudioPostProcessing.bash" >> "/config/sabnzbd.ini" + echo "newzbin = \"\"" >> "/config/sabnzbd.ini" + echo "order = 3" >> "/config/sabnzbd.ini" + echo "dir = lidarr" >> "/config/sabnzbd.ini" + fi + + if [ ! -f "/config/scripts/sab-config-updated" ]; then + touch "/config/scripts/sab-config-updated" + fi fi + # start cron + service cron stop fi - exit 0