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

Fix/transmission-default-open #813

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

flying-sausages
Copy link
Member

@flying-sausages flying-sausages commented Jan 15, 2022

Tranmission web port is open if nginx is installed so we should probably close that

@github-actions
Copy link

sh-checker report

shellcheck output
No errors or shellcheck is disabled

The files above have some shellcheck issues

shfmt output
--- scripts/nginx/transmission.sh.orig
+++ scripts/nginx/transmission.sh
@@ -1,65 +1,65 @@
 #!/bin/bash
 # nginx setup for transmission
 # by liara for swizzin
 # copyright 2020 swizzin.ltd
 
 users=($(cut -d: -f1 < /etc/htpasswd))
 
 if [[ ! -f /etc/nginx/apps/transmission.conf ]]; then
     cat > /etc/nginx/apps/transmission.conf << TCONF
 location /transmission {
     return 301 /transmission/web/;
 }
 
 location /transmission/ {
     proxy_set_header X-Real-IP \$remote_addr;
     proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
     proxy_set_header Host \$http_host;
     proxy_set_header X-NginX-Proxy true;
     proxy_http_version 1.1;
     proxy_set_header Connection "";
     proxy_pass_header X-Transmission-Session-Id;
     add_header   Front-End-Https   on;
     auth_basic "What's the password?";
     auth_basic_user_file /etc/htpasswd;
     proxy_pass http://\$remote_user.transmission;
 }
 TCONF
 fi
 
 for u in ${users[@]}; do
     active=$(systemctl is-active transmission@$u)
     echo_log_only "Service for $u was $active"
     if [[ $active == "active" ]]; then
         systemctl stop transmission@${u}
     fi
 
     timeout=0
     while systemctl is-active transmission@"$u" > /dev/null; do
         # echo "is active"
         timeout+=0.3
         if [[ $timeout -ge 20 ]]; then
             echo_error "The service transmission@$u took too long to shut down. Aborting."
             exit 1
         fi
         sleep 0.3
     done
 
     confpath="/home/${u}/.config/transmission-daemon/settings.json"
 
     jq '.["rpc-bind-address"] = "127.0.0.1"' "$confpath" >> "${confpath}.tmp"
     mv "${confpath}.tmp" "$confpath"
-    
+
     RPCPORT=$(jq -r '.["rpc-port"]' < "$confpath")
     cat > /etc/nginx/conf.d/${u}.transmission.conf << TDCONF
 upstream ${u}.transmission {
     server 127.0.0.1:${RPCPORT};
 }
 TDCONF
-    
+
     if [[ $active == "active" ]]; then
         systemctl start transmission@${u}
         echo_log_only "Activating service"
     fi
 done
 

The files above have some formatting problems, you can use shfmt -w to fix them

To get the full details about this job

@github-actions
Copy link

sh-checker report

shellcheck output
No errors or shellcheck is disabled

The files above have some shellcheck issues

shfmt output
--- scripts/nginx/transmission.sh.orig
+++ scripts/nginx/transmission.sh
@@ -1,65 +1,65 @@
 #!/bin/bash
 # nginx setup for transmission
 # by liara for swizzin
 # copyright 2020 swizzin.ltd
 
 users=($(cut -d: -f1 < /etc/htpasswd))
 
 if [[ ! -f /etc/nginx/apps/transmission.conf ]]; then
     cat > /etc/nginx/apps/transmission.conf << TCONF
 location /transmission {
     return 301 /transmission/web/;
 }
 
 location /transmission/ {
     proxy_set_header X-Real-IP \$remote_addr;
     proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
     proxy_set_header Host \$http_host;
     proxy_set_header X-NginX-Proxy true;
     proxy_http_version 1.1;
     proxy_set_header Connection "";
     proxy_pass_header X-Transmission-Session-Id;
     add_header   Front-End-Https   on;
     auth_basic "What's the password?";
     auth_basic_user_file /etc/htpasswd;
     proxy_pass http://\$remote_user.transmission;
 }
 TCONF
 fi
 
 for u in ${users[@]}; do
     active=$(systemctl is-active transmission@$u)
     echo_log_only "Service for $u was $active"
     if [[ $active == "active" ]]; then
         systemctl stop transmission@${u}
     fi
 
     timeout=0
     while systemctl is-active transmission@"$u" > /dev/null; do
         # echo "is active"
         timeout+=0.3
         if [[ $timeout -ge 20 ]]; then
             echo_error "The service transmission@$u took too long to shut down. Aborting."
             exit 1
         fi
         sleep 0.3
     done
 
     confpath="/home/${u}/.config/transmission-daemon/settings.json"
 
     jq '.["rpc-bind-address"] = "127.0.0.1"' "$confpath" >> "${confpath}.tmp"
     mv "${confpath}.tmp" "$confpath"
-    
+
     RPCPORT=$(jq -r '.["rpc-port"]' < "$confpath")
     cat > /etc/nginx/conf.d/${u}.transmission.conf << TDCONF
 upstream ${u}.transmission {
     server 127.0.0.1:${RPCPORT};
 }
 TDCONF
-    
+
     if [[ $active == "active" ]]; then
         systemctl start transmission@${u}
         echo_log_only "Activating service"
     fi
 done
 
--- scripts/update/transmission.sh.orig
+++ scripts/update/transmission.sh
@@ -1,48 +1,47 @@
 #!/bin/bash
 
 if [ -f /install/.transmission.lock ]; then
 
     if ! grep -q "\-\-logfile" /etc/systemd/system/[email protected]; then
         echo_progress_start "Moving transmission's logs to a file instead of syslog"
         sed "s|ExecStart=.*|ExecStart=/usr/bin/transmission-daemon -f --log-error --logfile /home/%i/.config/transmission-daemon/transmission.log|g" -i /etc/systemd/system/[email protected]
         systemctl daemon-reload
         readarray -t users < <(_get_user_list)
         for user in "${users[@]}"; do
             systemctl restart transmission@"$user"
         done
         echo_progress_done "Logs moved for all users"
     fi
 
-    
     echo_log_only "Checking if transmission ports are open if nginx is installed"
     ran='false'
     for user in $(_get_user_list); do
         confpath="/home/${user}/.config/transmission-daemon/settings.json"
         if jq '.["rpc-bind-address"]' "$confpath" | grep -q '0.0.0.0'; then
             if [ -f /install/.nginx.log ]; then
                 if [[ "${ran}" == "false" ]]; then
                     echo_info "Closing open un-proxied ports for transmission daemons"
                 fi
                 ran='true'
                 isActive=$(systemctl is-active transmission@"${user}")
                 if [[ $isActive == "active" ]]; then
                     systemctl stop transmission@"${user}"
                 fi
-                
+
                 jq '.["rpc-bind-address"] = "127.0.0.1"' "$confpath" >> "${confpath}.tmp"
                 mv "${confpath}.tmp" "$confpath"
 
                 if [[ $isActive == "active" ]]; then
                     systemctl start transmission@"${user}"
                 fi
             fi
         fi
     done
     if [[ "${ran}" == "true" ]]; then
         echo_warn "Please ensure that your existing connections to transmission work, specifically from systems not running on this host.\n
         In case you encounter any issues, please consult this guide:\n
         https://swizzin.ltd/applications/transmission/#connecting-to-transmission-remote"
     fi
 
 fi
 

The files above have some formatting problems, you can use shfmt -w to fix them

To get the full details about this job

@flying-sausages flying-sausages marked this pull request as ready for review July 15, 2023 17:34
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

Successfully merging this pull request may close these issues.

None yet

1 participant