Skip to content

Instantly share code, notes, and snippets.

@ZEROF
Last active August 29, 2015 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZEROF/065b8708cbe3cd62d83d to your computer and use it in GitHub Desktop.
Save ZEROF/065b8708cbe3cd62d83d to your computer and use it in GitHub Desktop.
Node watch installation script
#!/bin/bash
# This script will help you to set Nodewatch (http://vpsantiabuse.com/).
# Tested with Debian 7 32/64bit.
# Script 2nd hand author ZEROF <zerof@backbox.org>
# Idea was born here https://vpsaddicted.com/installing-and-configuring-nodewatch-on-debian-7/
# If you like Linux and security join http://backbox.org
# Script version 0.3b
# This script is distributed under a DO WHAT THE F*** YOU WANT TO PUBLIC LICENSE.
# http://rmlh.me/license.html
# If you are not root, find a place where you can be
# Check user
if [ $USER != 'root' ]; then
echo "[!]Are you root? NO. Then try again."
exit
fi
# Check path
print=$(printf '%s\n' "${PWD##*/}");
if [ $print != root ];then
echo "Wrong path, run this script from /root directory"
exit
fi
# Simple next/go function
function enter ()
{
echo ""
read -sn 1 -p "Press any key to continue..."
clear
}
# Install Nodewatch
function installation ()
{
apt-get update
apt-get -y install patch zlib1g-dev libbz2-dev gcc openssl libssl-dev make re2c bison flex libltdl-dev libltdl7 libsslcommon2-dev libcurl4-openssl-dev libmcrypt-dev
rm -rf /root/nodewatch/build/*
rm -rf /nodewatch/php/*
mkdir -p /root/nodewatch/build
mkdir -p /nodewatch/php
cd /root/nodewatch/build
wget http://deploy.vpsantiabuse.com/php-5.2.17.tar.gz
tar -zxf php-*
cd php-*
#Disable SSLv2
wget http://linux.gungoos.com/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch.patch.txt -O ssl.patch
patch -p1 < ssl.patch
./configure --silent --with-config-file-path=/nodewatch/php --prefix=/nodewatch/php --disable-all --enable-ipv6 --disable-json --enable-magic-quotes --without-sqlite --with-zlib --without-gd --without-ttf --disable-debug --disable-rpath --without-pear --without-pgsql --enable-mbstring --with-bz2 --without-iconv --without-gettext --without-curl --with-pcre-regex --with-openssl
make -j8 --silent
make install
rm -rf /root/nodewatch/build/*
cd /nodewatch/php
rm -f ioncube_loader_lin_5.2_x86_64.so
wget http://deploy.vpsantiabuse.com/ioncube_loader_lin_5.2_x86_64.so
cd /nodewatch/php
rm -f php.ini
wget -nv http://deploy.vpsantiabuse.com/php.ini
echo '*/5 * * * * root /nodewatch/php/bin/php /nodewatch/scripts/nodewatch_cron5min.php' > /etc/cron.d/vpsantiabuse
rm -rf /root/nodewatch/jripper
mkdir -p /root/nodewatch/jripper
cd /root/nodewatch/jripper
wget http://deploy.vpsantiabuse.com/john-1.7.9-jumbo-5.tar.gz
tar -zxf john-*
cd john-*/src
make -j8 linux-x86-64i
cd ../run
mkdir -p /nodewatch/bin/john/
mv -f ./john /nodewatch/bin/john/
cd ..
wget -nv http://deploy.vpsantiabuse.com/password.lst
mv -f ./password.lst /nodewatch/bin/john/
cd ~
rm -rf /root/nodewatch/jripper
cd /nodewatch/bin/john
rm -f john.conf
wget -nv http://deploy.vpsantiabuse.com/john.conf
echo 'watch -n 1 cat /tmp/nodewatch_stats' > /nodewatch.sh
chmod 0700 /nodewatch.sh
mkdir -p /nodewatch/scripts
cd /nodewatch/scripts
rm -f update.sh
wget -nv http://deploy.vpsantiabuse.com/nodewatch/update.sh
chmod 0700 update.sh
echo **************************************************************
echo Installation complete. Updating nodewatch to latest version...
echo **************************************************************
sleep 2
echo
./update.sh
}
# By default, Nodewatch gets the VPS infos from /etc/sysconfig/vz-scripts/, this directory is different on Debian (it’s /etc/vz/conf/ on debian).
# The solution: Create a symlink to link the vm configuration directory to /etc/sysconfig/vz-scripts/.
function symlink1 ()
{
mkdir /etc/sysconfig
ln -s /etc/vz/conf /etc/sysconfig/vz-scripts
}
# You have to do the same for the directory /vz/root. Nodewatch searches for server infos in this directory and it doesn’t exist,
# that’s why we you also have to create a symlink, pointing /var/lib/vz to /vz/root.
function symlink2 ()
{
ln -s /var/lib/vz /vz
}
# Set mail to get alerts
function mailos ()
{
cd /nodewatch/scripts
echo -e -n "Set your mail for Nodewatch alerts: "
read mailito
mail1="$admin_email = '';"
mail2="$admin_email = '$mailito';"
sed -i "21s|$mail1|$mail2|" nodewatch_config.php
}
# Set licence key from vpsantiabuse.com
function serialos ()
{
cd /nodewatch/scripts
echo -e -n "Put your Nodewatch licence key: "
read key
key1="$license_key = '';"
key2="$license_key = '$key';"
sed -i "24s|$key1|$key2|" nodewatch_config.php
}
# Remove Nodewatch
function remove () {
rm -f /etc/cron.d/vpsantiabuse
bash /nodewatch/scripts/nodewatch_restart.sh
rm -rf /root/nodewatch
unlink /etc/sysconfig/vz-scripts
unlink /vz
rm -rf /etc/sysconfig
}
#Menu
selection=
until [ "$selection" = "0" ]; do
echo ""
echo "Nodewatch Debian 7 installation"
echo ""
echo "1 - install Nodewatch"
echo "2 - create symlinks [!]"
echo "3 - set your email for Nodewatch alerts"
echo "4 - set your Nodewatch licence key"
echo "5 - restart Nodewatch"
echo "6 - remove Nodewatch"
echo ""
echo "0 - exit program"
echo ""
echo -n "Enter selection: "
read selection
echo ""
case $selection in
1 ) installation;enter ;;
2 ) symlink1;symlink2;enter ;;
3 ) mailos;enter ;;
4 ) serialos;enter ;;
5 ) bash /nodewatch/scripts/nodewatch_restart.sh; enter ;;
6 ) remove;enter ;;
0 ) exit ;;
* ) echo "Please enter 1, 2, 3, 4, 5, 6 or 0"
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment