Browse Source

tahoe web interface

Bob Mottram 8 years ago
parent
commit
3c65d3b6c1
1 changed files with 46 additions and 0 deletions
  1. 46
    0
      src/freedombone-app-tahoelafs

+ 46
- 0
src/freedombone-app-tahoelafs View File

@@ -38,6 +38,7 @@ TAHOELAFS_REPO="https://github.com/tahoe-lafs/tahoe-lafs"
38 38
 TAHOELAFS_COMMIT='bb782b0331a60de438136a593bba18338d8d866b'
39 39
 
40 40
 TAHOELAFS_PORT=50213
41
+TAHOELAFS_WEB_PORT=50214
41 42
 TAHOELAFS_ONION_PORT=8096
42 43
 
43 44
 TAHOELAFS_SHARED_DIR='Shared'
@@ -82,6 +83,7 @@ function tahoelafs_setup_config {
82 83
     sed -i "s|tub.location.*|tub.location = tor:${TAHOELAFS_ONION_HOSTNAME}:${TAHOELAFS_PORT}|g" $config_file
83 84
 
84 85
     sed -i "s|nickname =.*|nickname = $HOSTNAME|g" $config_file
86
+    sed -i "s|web.port =.*|web.port = tcp:$TAHOELAFS_WEB_PORT:interface=127.0.0.1|g" $config_file
85 87
 
86 88
     if ! grep -q "[storage]" $config_file; then
87 89
         echo '' >> $config_file
@@ -170,6 +172,15 @@ function reconfigure_tahoelafs {
170 172
 }
171 173
 
172 174
 function remove_tahoelafs {
175
+    if [ -f /etc/nginx/sites-available/tahoelafs ]; then
176
+        nginx_dissite tahoelafs
177
+        rm /etc/nginx/sites-available/tahoelafs
178
+        if [ -d /var/www/tahoelafs ]; then
179
+            rm -rf /var/www/tahoelafs
180
+        fi
181
+        systemctl reload nginx
182
+    fi
183
+
173 184
     systemctl stop tahoelafs
174 185
     systemctl disable tahoelafs
175 186
     rm /etc/systemd/system/tahoelafs.service
@@ -277,6 +288,41 @@ function install_tahoelafs {
277 288
 
278 289
     set_completion_param "tahoelafs commit" "$TAHOELAFS_COMMIT"
279 290
 
291
+    if [ ! -d /var/www/tahoelafs ]; then
292
+        mkdir -p /var/www/tahoelafs/htdocs
293
+    fi
294
+
295
+    tahoelafs_nginx_site=/etc/nginx/sites-available/tahoelafs
296
+    echo 'server {' > $tahoelafs_nginx_site
297
+    echo "    listen 127.0.0.1:$TAHOELAFS_ONION_PORT default_server;" >> $tahoelafs_nginx_site
298
+    echo "    server_name $TAHOELAFS_ONION_HOSTNAME;" >> $tahoelafs_nginx_site
299
+    echo '' >> $tahoelafs_nginx_site
300
+    function_check nginx_disable_sniffing
301
+    nginx_disable_sniffing tahoelafs
302
+    echo '' >> $tahoelafs_nginx_site
303
+    echo '  # Logs' >> $tahoelafs_nginx_site
304
+    echo '  access_log /dev/null;' >> $tahoelafs_nginx_site
305
+    echo '  error_log /dev/null;' >> $tahoelafs_nginx_site
306
+    echo '' >> $tahoelafs_nginx_site
307
+    echo '  # Root' >> $tahoelafs_nginx_site
308
+    echo "  root /var/www/tahoelafs/htdocs;" >> $tahoelafs_nginx_site
309
+    echo '' >> $tahoelafs_nginx_site
310
+    echo '  location / {' >> $tahoelafs_nginx_site
311
+    function_check nginx_limits
312
+    nginx_limits tahoelafs '15m'
313
+    echo '    rewrite /(.*) /$1 break;' >> $tahoelafs_nginx_site
314
+    echo '    proxy_set_header X-Real-IP $remote_addr;' >> $tahoelafs_nginx_site
315
+    echo '    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $tahoelafs_nginx_site
316
+    echo '    proxy_set_header Host $http_host;' >> $tahoelafs_nginx_site
317
+    echo '    proxy_set_header X-NginX-Proxy true;' >> $tahoelafs_nginx_site
318
+    echo "    proxy_pass http://localhost:${TAHOELAFS_WEB_PORT};" >> $tahoelafs_nginx_site
319
+    echo '    proxy_redirect off;' >> $tahoelafs_nginx_site
320
+    echo '  }' >> $tahoelafs_nginx_site
321
+    echo '}' >> $tahoelafs_nginx_site
322
+
323
+    function_check nginx_ensite
324
+    nginx_ensite tahoelafs
325
+
280 326
     APP_INSTALLED=1
281 327
 }
282 328