From fee1fefdb8e918d40afe2b50659b8f3eef60cc08 Mon Sep 17 00:00:00 2001 From: jonnyboy Date: Mon, 4 Feb 2013 00:04:17 +0100 Subject: [PATCH] removed dark blue from colors, removed sudo in script, now require either sudo or root to start the script, added removal of tmpfs and tmpunrar1 to revert.sh --- README.md | 2 +- bin/monitor.php | 4 +++- scripts/revert.sh | 24 +++++++++++++++++++++--- scripts/set_perms.sh | 6 ++++++ start.sh | 38 ++++++++++++++++++++++---------------- 5 files changed, 53 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7e785b74b..bf43e2ed8 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ cd scripts && ./set_perms.sh ``` - * Run my script, as user. If, you have grsecurity in you kernel, you will need to run using sudo if you use nmon or bwm-ng. + * Run my script, as user. There are many parts that require sudo or root, especially if you have grsec compliled into the kernel. I have put checks in that will require elevated priviledges. ```bash cd ../ && ./start.sh diff --git a/bin/monitor.php b/bin/monitor.php index 3a5f04d82..c86c501ab 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -41,7 +41,9 @@ $_sleep_string = "\033[1;31msleeping\033[0m "; function get_color() { - return (mt_rand(1,230)); + $number = mt_rand(1,230); + if ( $number == 16 || $number == 17 ) { get_color(); } + return($number); } $time = TIME(); diff --git a/scripts/revert.sh b/scripts/revert.sh index 4fd388b93..8c26185be 100755 --- a/scripts/revert.sh +++ b/scripts/revert.sh @@ -9,9 +9,14 @@ do done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + source ../defaults.sh - - +eval $( $SED -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" "$NEWZPATH"/www/config.php ) if [ -f $NEWZPATH/www/lib/postprocess.php ]; then sudo $SED -i -e 's/\/\/$this->processAdditional();/$this->processAdditional();/' $NEWZPATH/www/lib/postprocess.php @@ -27,6 +32,19 @@ if [ -f $NEWZPATH/www/lib/postprocess.php ]; then sudo $SED -i -e 's/\/\/$this->processUnknownCategory();/$this->processUnknownCategory();/' $NEWZPATH/www/lib/postprocess.php fi -echo "my edits have been removed" +#Get the path to tmpunrar +TMPUNRAR_QUERY="SELECT value from site where setting = \"tmpunrarpath\";" +TMPUNRAR_PATH=`$MYSQL --defaults-extra-file=../conf/my.cnf -u$DB_USER -h$DB_HOST $DB_NAME -s -N -e "${TMPUNRAR_QUERY}"` +TMPUNRAR_PATH=$TMPUNRAR_PATH"1" + +#remove the ramdisk +if [[ ! `mountpoint -q $TMPUNRAR_PATH` ]]; then + umount $TMPUNRAR_PATH +fi + +#remove the temp folder +rm -r $TMPUNRAR_PATH + +echo "My edits have been removed" exit diff --git a/scripts/set_perms.sh b/scripts/set_perms.sh index 6c63cb538..028df080d 100755 --- a/scripts/set_perms.sh +++ b/scripts/set_perms.sh @@ -9,6 +9,12 @@ do done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + source ../defaults.sh clear diff --git a/start.sh b/start.sh index 86f11bacc..f48132143 100755 --- a/start.sh +++ b/start.sh @@ -15,6 +15,12 @@ if [ ! -f defaults.sh ]; then exit fi +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + source defaults.sh #verify all variables exist @@ -34,40 +40,40 @@ if [[ $AGREED == "no" ]]; then fi if [ ! -f $NEWZPATH/www/lib/postprocess.php.orig ]; then - sudo cp $NEWZPATH/www/lib/postprocess.php $NEWZPATH/www/lib/postprocess.php.orig + cp $NEWZPATH/www/lib/postprocess.php $NEWZPATH/www/lib/postprocess.php.orig fi if ! grep -q '//$this->processAdditional();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processAdditional();/\/\/$this->processAdditional();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processAdditional();/\/\/$this->processAdditional();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processNfos();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processNfos();/\/\/$this->processNfos();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processNfos();/\/\/$this->processNfos();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processUnwanted();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processUnwanted();/\/\/$this->processUnwanted();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processUnwanted();/\/\/$this->processUnwanted();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processMovies();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processMovies();/\/\/$this->processMovies();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processMovies();/\/\/$this->processMovies();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processMusic();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processMusic();/\/\/$this->processMusic();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processMusic();/\/\/$this->processMusic();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processBooks();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processBooks();/\/\/$this->processBooks();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processBooks();/\/\/$this->processBooks();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processGames();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processGames();/\/\/$this->processGames();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processGames();/\/\/$this->processGames();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processTv();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processTv();/\/\/$this->processTv();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processTv();/\/\/$this->processTv();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processMusicFromMediaInfo();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processMusicFromMediaInfo();/\/\/$this->processMusicFromMediaInfo();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processMusicFromMediaInfo();/\/\/$this->processMusicFromMediaInfo();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processOtherMiscCategory();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processOtherMiscCategory();/\/\/$this->processOtherMiscCategory();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processOtherMiscCategory();/\/\/$this->processOtherMiscCategory();/' $NEWZPATH/www/lib/postprocess.php fi if ! grep -q '//$this->processUnknownCategory();' "$NEWZPATH/www/lib/postprocess.php" ; then - sudo $SED -i -e 's/$this->processUnknownCategory();/\/\/$this->processUnknownCategory();/' $NEWZPATH/www/lib/postprocess.php + $SED -i -e 's/$this->processUnknownCategory();/\/\/$this->processUnknownCategory();/' $NEWZPATH/www/lib/postprocess.php fi #create mysql my.conf @@ -84,14 +90,14 @@ fi TMPUNRAR_QUERY="SELECT value from site where setting = \"tmpunrarpath\";" TMPUNRAR_PATH=`$MYSQL --defaults-extra-file=conf/my.cnf -u$DB_USER -h$DB_HOST $DB_NAME -s -N -e "${TMPUNRAR_QUERY}"` TMPUNRAR_PATH=$TMPUNRAR_PATH"1" -sudo mkdir -p $TMPUNRAR_PATH +mkdir -p $TMPUNRAR_PATH #create a ramdisk if [[ $RAMDISK == "true" ]]; then - mountpoint -q $TMPUNRAR_PATH || sudo mount -t tmpfs -o size=32M tmpfs $TMPUNRAR_PATH 2>&1 > /dev/null + mountpoint -q $TMPUNRAR_PATH || mount -t tmpfs -o size=32M tmpfs $TMPUNRAR_PATH 2>&1 > /dev/null fi -sudo chmod -R 777 $TMPUNRAR_PATH +chmod -R 777 $TMPUNRAR_PATH #remove postprocessing scripts rm -f bin/lib/post* @@ -124,7 +130,7 @@ sed -i -e "s/\$tmpPath = \$this->site->tmpunrarpath;/\$tmpPath = \$this->site->t sed -i -e 's/order by r.postdate desc limit %d.*$/order by r.guid desc limit %d ", ($maxattemptstocheckpassworded + 1) * -1, $numtoProcess));/g' bin/lib/postprocess1.php sed -i -e 's/PostPrc : Performing additional post processing.*$/PostPrc : Performing additional post processing by guid on ".$rescount." releases ...";/g' bin/lib/postprocess1.php -sudo chmod -R 777 $TMPUNRAR_PATH +chmod -R 777 $TMPUNRAR_PATH printf "\033]0; $TMUX_SESSION\007\003\n" $TMUXCMD -f $TMUX_CONF new-session -d -s $TMUX_SESSION -n $TMUX_SESSION 'cd bin && echo "Monitor Started" && echo "It might take a minute for everything to spinup......" && $NICE -n 19 $PHP monitor.php'