From 0a511bdbfeb116027561da69523be2893ab96b79 Mon Sep 17 00:00:00 2001 From: arakasi72 Date: Thu, 17 Aug 2017 11:08:18 +0100 Subject: [PATCH] Develop (#249) * Update rtsetup * Update rtsetup * Update rtsetup * Update rtsetup * Delete rtgetscripts * Update rtversion * Update rtinst * Update rtsetup * Update rtsetup * Update rtsetup --- rtsetup | 26 ++++++++++++++++++ scripts/rtgetscripts | 65 -------------------------------------------- scripts/rtinst | 5 ++-- scripts/rtversion | 4 +-- 4 files changed, 31 insertions(+), 69 deletions(-) delete mode 100755 scripts/rtgetscripts diff --git a/rtsetup b/rtsetup index 2d2ac92..7fad6c6 100755 --- a/rtsetup +++ b/rtsetup @@ -13,6 +13,19 @@ PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin rundir=$(dirname $(readlink -f $0)) branch=$1 +# 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 +} + if [ "$(id -u)" != "0" ]; then echo "Must be run as root, directly or with sudo" exit 1 @@ -34,6 +47,19 @@ if [ -d /etc/rtinst ] && [ -z $branch ]; then branch=$(basename "$(git symbolic-ref -q HEAD)") if [ -z $branch ]; then branch=$(git describe --tags --exact-match) + if [ ${branch:0:1} = v ]; then + latest=$(basename "$(git ls-remote --tags https://github.com/arakasi72/rtinst.git | grep -o 'refs/tags/v.*' | sort -V | tail -1)") + if [ $branch != $latest ]; then + echo "Updating from $branch to $latest" + branch=$latest + else + echo "Already using the latest version, rtinst $branch" + echo -n "Do you wish to reinstall rtinst y/n? " + if ! ask_user; then + exit + fi + fi + fi fi if [ $(git ls-remote --tags --heads https://github.com/arakasi72/rtinst.git $branch | wc -l) -eq 0 ]; then echo "$branch has been deleted, using latest numbered release instead" diff --git a/scripts/rtgetscripts b/scripts/rtgetscripts deleted file mode 100755 index 1dab1a2..0000000 --- a/scripts/rtgetscripts +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -###################################################################### -# -# Copyright (c) 2015 arakasi72 (https://github.com/arakasi72) -# -# --> 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 - -if [ "$(id -u)" != "0" ]; then - echo "Must be run as root, directly or with sudo" - exit 1 -fi - -if [ ! -d /etc/rtinst ]; then - git clone https://github.com/arakasi72/rtinst.git /etc/rtinst -fi - -cd /etc/rtinst - -branch=$(basename "$(git symbolic-ref -q HEAD)") - -# if branch is empty then it is a tag -if [ -z $branch ]; then - branch=$(git describe --tags --exact-match) - if [ ${branch:0:1} = v ]; then - latest=$(basename "$(git ls-remote --tags https://github.com/arakasi72/rtinst.git | grep -o 'refs/tags/v.*' | sort -V | tail -1)") - if [ $branch = $latest ]; then - echo "Already using the latest release: $branch" - exit - fi - # update to latest release - echo "rtinst updating from $branch to $latest" - cd - rm -fr /etc/rtinst - git clone -q https://github.com/arakasi72/rtinst.git /etc/rtinst - cd /etc/rtinst - git checkout -q $latest - branch=$(git describe --tags --exact-match) - echo "rtinst $branch installed" - cd - ln -sf /etc/rtinst/scripts/* /usr/local/bin - ln -sf /etc/rtinst/rtsetup /usr/local/bin - exit - else - echo "$branch is not a branch, or a numbered release" - echo "Run rtsetup if you want to switch to another build" - exit - fi -fi - -if [ $(git ls-remote --heads https://github.com/arakasi72/rtinst.git $branch | wc -l) -eq 0 ]; then - echo "$branch no longer appears to exist" - echo "run rtsetup to reset branch" -else - git fetch --all - git reset --hard origin/$branch > /dev/null 2>&1 - git pull origin $branch - - ln -sf /etc/rtinst/scripts/* /usr/local/bin - ln -sf /etc/rtinst/rtsetup /usr/local/bin -fi diff --git a/scripts/rtinst b/scripts/rtinst index 39ea483..2c459cc 100755 --- a/scripts/rtinst +++ b/scripts/rtinst @@ -52,7 +52,7 @@ portdefault=1 skip_rt=1 sshport='' -rudevflag=0 +rudevflag=1 passfile='/etc/nginx/.htpasswd' package_list="sudo nano autoconf build-essential ca-certificates comerr-dev curl cfv dtach htop irssi libcloog-ppl-dev libcppunit-dev libcurl3 libncurses5-dev libterm-readline-gnu-perl libsigc++-2.0-dev libperl-dev libtool libxml2-dev ncurses-base ncurses-term ntp patch pkg-config $phpver-fpm $phpver $phpver-cli $phpver-dev $phpver-curl $geoipver $phpver-mcrypt $phpver-xmlrpc python-scgi screen subversion texinfo unzip zlib1g-dev libcurl4-openssl-dev mediainfo python-software-properties software-properties-common aptitude $phpver-json nginx-full apache2-utils git libarchive-zip-perl libnet-ssleay-perl libhtml-parser-perl libxml-libxml-perl libjson-perl libjson-xs-perl libxml-libxslt-perl libjson-rpc-perl libarchive-zip-perl" Install_list="" @@ -226,7 +226,7 @@ else fi # get options -OPTS=$(getopt -n "$0" -o dltryu:p:w: --long "dload,log,ssh-default,rutorrent-stable,force-yes,user:,password:,webpass:" -- "$@") +OPTS=$(getopt -n "$0" -o dltrmyu:p:w: --long "dload,log,ssh-default,rutorrent-stable,rutorrent-master,force-yes,user:,password:,webpass:" -- "$@") eval set -- "$OPTS" @@ -236,6 +236,7 @@ while true; do -l | --log ) logfile="$HOME/rtinst.log"; shift ;; -t | --ssh-default ) portdefault=0; shift;; -r | --rutorrent-stable ) rudevflag=1; shift;; + -m | --rutorrent-master ) rudevflag=0; shift;; -y | --force-yes ) forceyes=0; shift;; -u | --user ) user="$2"; shift; shift;; -p | --password ) unixpass="$2"; shift; shift;; diff --git a/scripts/rtversion b/scripts/rtversion index 761245d..6539cf6 100755 --- a/scripts/rtversion +++ b/scripts/rtversion @@ -48,10 +48,10 @@ if [ -z $branch ]; then if [ $branch = $latest ]; then echo "This is the latest release" else - echo "Use rtgetscripts to update to rtinst $latest" + echo "Use rtsetup to update to rtinst $latest" fi fi else echo "Current Branch: $branch" - echo "Use rtgetscripts to update branch" + echo "Use rtsetup to update branch" fi