1
0
mirror of https://github.com/elisspace/rtinst.git synced 2026-08-31 16:34:16 +00:00
Files
rtinst/scripts/rtdload
2015-11-08 19:19:41 +00:00

53 lines
2.1 KiB
Bash

#!/bin/bash
######################################################################
#
# Copyright (c) 2015 arakasi72 (https://github.com/arakasi72)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights t$
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS O$
#
# --> Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
#
######################################################################
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
lineno=$(sed -n '/dload-loc/=' /etc/nginx/sites-available/default)
if ! [ "$LOGNAME" = "root" ]; then
echo "Must be run as root, directly or with sudo"
exit 1
fi
if [ -f /etc/nginx/conf.d/rtdload ]; then rm -f /etc/nginx/conf.d/rtdload; fi
sed -i '/rtdload/d' /etc/nginx/sites-available/default
if [ "$1" = "enable" ]; then
if ! [ -f /etc/nginx/sites-available/dload-loc ]; then
rtgetscripts
rtgetscripts /etc/nginx/sites-available/dload-loc nginxsitedl
fi
if [ -z "$lineno" ]; then
sed -i '/location \~ \/\\\.ht/ i\ include \/etc\/nginx\/sites-available\/dload-loc;\n' /etc/nginx/sites-available/default
else
sed -i '/dload-loc/ c\ include \/etc\/nginx\/sites-available\/dload-loc;' /etc/nginx/sites-available/default
fi
service nginx reload
echo "http download enabled"
elif [ "$1" = "disable" ]; then
if ! [ -z "$lineno" ]; then
sed -i '/dload-loc/ c\ #include \/etc\/nginx\/sites-available\/dload-loc;' /etc/nginx/sites-available/default
service nginx reload
fi
echo "http download disabled"
else
echo "argument must be enable or disable"
exit 1
fi