Skip to content

Commit

Permalink
Develop (#424)
Browse files Browse the repository at this point in the history
* Update rtinst

* Update rtinst

* Update rtinst

* Update rtorrent.rc

* Update rtadduser

* Update rtadduser

* Update rtadduser

* Update rtadduser

* Update rtadduser

* Update rtadduser

* Update rtadduser

* Update rtletsencrypt
  • Loading branch information
arakasi72 authored Aug 7, 2019
1 parent bb7e6bf commit 3b2b678
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 37 deletions.
2 changes: 2 additions & 0 deletions conf/rtorrent.rc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ directory.default.set = (cat,(cfg.basedir),"download")

schedule = watch_directory,5,5,((load.start,(cat,(cfg.watch),"*.torrent")))

#system.umask.set = 0000

### BitTorrent
# Global upload and download rate in KiB, `0` for unlimited
throttle.global_down.max_rate.set = 0
Expand Down
85 changes: 56 additions & 29 deletions scripts/rtadduser
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ sshport=$(grep 'Port ' /etc/ssh/sshd_config | sed 's/[^0-9]*//g')
ftpport=$(grep 'listen_port=' /etc/vsftpd.conf | sed 's/[^0-9]*//g')
cronline1="@reboot sleep 10; /usr/local/bin/rtcheck irssi rtorrent"
cronline2="*/10 * * * * /usr/local/bin/rtcheck irssi rtorrent"
serverip=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
serverip=$(ip route get 8.8.8.8 | awk 'NR==1 {print $7}')
check_ssh=1
rtdstatus=$(rtdload)

#get user list
cd /var/www/rutorrent/conf/users
Expand All @@ -33,6 +34,28 @@ user_list=*
### FUNCTIONS ###
###############################

#function to determin if unix user name is valid
valid_name(){
until [[ $user =~ ^[a-z][-a-z0-9_]{2,31}$ ]]
do
echo "Enter user name (lowercase, numbers, dash and underscore):"
read user
done
}

# function to ask user for y/n response
ask_user(){
local answer
while true
do
read answer
case $answer in [Yy]* ) return 0 ;;
[Nn]* ) return 1 ;;
* ) echo "Enter y or n";;
esac
done
}

genpasswd() {
local genln=$1
[ -z "$genln" ] && genln=8
Expand Down Expand Up @@ -183,34 +206,39 @@ fi
###############################

if [ -z "$user" ]; then
echo "Enter the name of the user to add"
echo "Enter the name of the user"
echo "It can be an existing user or a new user"
echo

confirm_name=1
while [ $confirm_name = 1 ]
do
read -p "Enter user name: " answer
addname=$answer
check_name=1
if [ "$addname" = "root" ]; then
echo "Cannot create root"
exit
valid_name
echo -n "Confirm that user name is $user y/n? "
if ask_user; then
confirm_name=0
else
user=''
fi

while [ $check_name = 1 ]
do
read -p "Is $addname correct? " answer
case $answer in [Yy]* ) confirm_name=0 && check_name=0 ;;
[Nn]* ) confirm_name=1 && check_name=0 ;;
* ) echo "Enter y or n";;
esac
done
done

user=$addname
else
if ! [[ $user =~ ^[a-z][-a-z0-9_]{2,31}$ ]]; then
echo "$user is not a valid user name please enter again"
confirm_name=1
while [ $confirm_name = 1 ]
do
valid_name
echo -n "Confirm that user name is $user y/n? "
if ask_user; then
confirm_name=0
else
user=''
fi
done
fi
fi

echo "User name is $user"

if id -u $user >/dev/null 2>&1; then
echo "$user already exists"
else
Expand All @@ -220,6 +248,13 @@ else
adduser --gecos "" $user --disabled-password
echo "$user:$unixpass" | sudo chpasswd
fi

if id -u $user >/dev/null 2>&1; then
echo "$user successfully created"
else
echo "create user failed - exiting process"
exit 1
fi
fi

home=$(eval echo "~$user")
Expand Down Expand Up @@ -363,14 +398,6 @@ fi
su $user -c '/usr/local/bin/rt restart'
su $user -c '/usr/local/bin/rt -i restart'

dload_line=$(grep "include /etc/nginx/conf.d/rtdload;" /etc/nginx/sites-available/default)
dload_hash=$(echo $dload_line | sed 's/[^#]*//g')
if [ ! -z "$dload_line" -a -z "$dload_hash" ]; then
dload_flag=0
else
dload_flag=1
fi

echo "$user setup complete"
echo "SCGI Port: $newscgi"
echo "RPC Mount: $newrpc"
Expand All @@ -391,7 +418,7 @@ echo
fi
echo "ftp client should be set to explicit ftp over tls using port $ftpport" | tee -a $home/rtinst.info
echo
if [ $dload_flag = 0 ]; then
if [ "$rtdstatus" = "enabled" ]; then
echo "https downloads can be accessed at https://$serverip/download/$user" | tee -a $home/rtinst.info
echo
fi
Expand Down
48 changes: 41 additions & 7 deletions scripts/rtinst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ else
fi
}

#function to determin if unix user name is valid
valid_name(){
until [[ $user =~ ^[a-z][-a-z0-9_]{2,31}$ ]]
do
echo "Enter user name (lowercase, numbers, dash and underscore):"
read user
done
}




#function to generate random password
genpasswd() {
local genln=$1
Expand Down Expand Up @@ -379,25 +391,39 @@ if [ -z "$user" ]; then
echo "This will be your primary user"
echo "It can be an existing user or a new user"
echo

confirm_name=1
while [ $confirm_name = 1 ]
do
read -p "Enter user name: " answer
addname=$answer
echo -n "Confirm that user name is $answer y/n? "
valid_name
echo -n "Confirm that user name is $user y/n? "
if ask_user; then
confirm_name=0
else
user=''
fi
done

user=$addname

else
user=$SUDO_USER
fi
else
if ! [[ $user =~ ^[a-z][-a-z0-9_]{2,31}$ ]]; then
echo "$user is not a valid user name please enter again"
confirm_name=1
while [ $confirm_name = 1 ]
do
valid_name
echo -n "Confirm that user name is $user y/n? "
if ask_user; then
confirm_name=0
else
user=''
fi
done
fi
fi

echo "User name is $user"

if id -u $user >/dev/null 2>&1; then
echo "$user already exists"
else
Expand All @@ -407,6 +433,14 @@ else
adduser --gecos "" $user --disabled-password
echo "$user:$unixpass" | chpasswd
fi

if id -u $user >/dev/null 2>&1; then
echo "$user successfully created"
else
echo "create user failed - exiting process"
exit 1
fi

fi

home=$(eval echo "~$user")
Expand Down
3 changes: 2 additions & 1 deletion scripts/rtletsencrypt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ if [ $(dpkg-query -W -f='${Status}' "certbot" 2>/dev/null | grep -c "ok installe
apt-get -q update >> $logfile 2>&1
apt-get install -y certbot python-certbot-nginx >> $logfile 2>&1
else
grep "^deb http\:\/\/deb\.debian\.org\/debian stretch-backports main" /etc/apt/sources.list > /dev/null || echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
deb_name=$(lsb_release --codename --short)
grep "^deb http\:\/\/deb\.debian\.org\/debian $deb_name-backports main" /etc/apt/sources.list > /dev/null || echo "deb http://deb.debian.org/debian $deb_name-backports main" >> /etc/apt/sources.list
apt-get -q update >> $logfile 2>&1
apt-get install -y certbot python-certbot-nginx -t stretch-backports >> $logfile 2>&1
fi
Expand Down

0 comments on commit 3b2b678

Please sign in to comment.