added script to create and to remove ramdisk, use at your own risk

This commit is contained in:
root
2013-03-21 02:35:02 -04:00
parent 9c5ca95e22
commit 6c19ec222d
4 changed files with 192 additions and 1 deletions
+2
View File
@@ -76,6 +76,8 @@
* Included in the scripts folder is revert.sh. This file will update your Newznab+ installation and overwrite the changes from these scripts. * Included in the scripts folder is revert.sh. This file will update your Newznab+ installation and overwrite the changes from these scripts.
* It is recommended, with stock scripts, that when backfilling or importing you set header retention to 0. This is not recommended when you are using these scripts. Let me explain why. If you start with empty parts/binaries tables and you import 100 nzbs, and at the same time you start update_releases, when update_releases finishes its loop, it deletes everything in the parts/binaries tables because you have header retention set to 0. But, heres where the problem is, youcontinued to import 200 nzbs while update_releases was running, they did not get imported as a release, they were deleted at the end of update_releases loop. So, I recommend you set header retention to at least .1, that is 2.4 hours, when only backfilling or importing.
* Almost any variable in defaults.sh can be changed, except the paths to the commands, and the changes will take effect on the next loop of the Monitor. * Almost any variable in defaults.sh can be changed, except the paths to the commands, and the changes will take effect on the next loop of the Monitor.
* If you connect using **putty**, then under Window/Translation set Remote character set to UTF-8 and check "Copy and paste line drawing characters". To use 256 colors, you must set Connection/Data Terminal-type string to "xterm-256color" and in Window/Colours check the top three boxes, otherwise only 16 colors are displayed. If you are using FreeBSD, you will need to add export TERM=xterm-256color to your .bashrc file to show 256 colors. * If you connect using **putty**, then under Window/Translation set Remote character set to UTF-8 and check "Copy and paste line drawing characters". To use 256 colors, you must set Connection/Data Terminal-type string to "xterm-256color" and in Window/Colours check the top three boxes, otherwise only 16 colors are displayed. If you are using FreeBSD, you will need to add export TERM=xterm-256color to your .bashrc file to show 256 colors.
+1 -1
View File
@@ -2,7 +2,7 @@
require(dirname(__FILE__)."/config.php"); require(dirname(__FILE__)."/config.php");
require(WWW_DIR.'/lib/postprocess.php'); require(WWW_DIR.'/lib/postprocess.php');
$version="0.1r740"; $version="0.1r741";
$db = new DB(); $db = new DB();
+107
View File
@@ -0,0 +1,107 @@
#!/usr/bin/env bash
SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
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"
exit 1
fi
source $DIR/../defaults.sh
#edit this to allow script to run, be sure of the paths
#the ramdisk needs to be twice the size of the parts table max size, it needs room to copy itself during optimise
#i take no responsibility if this fails and you lose you db
#remove the next 2 lines when you have edited this file properlly
echo "Please edit this script, very carefully!"
exit
export USER="username"
export PATH_RAMDISK="/var/ramdisk"
export MYSQL_PATH="/var/lib/mysql/newznab"
export SQL_BACKUP="/home/$USER/sql_backup"
/etc/init.d/mysql stop
if ! grep -q '#RAMDISK' "/etc/fstab" ; then
echo "" | sudo tee -a /etc/fstab
echo "#RAMDISK" | sudo tee -a /etc/fstab
echo "tmpfs $PATH_RAMDISK tmpfs user,nodev,nodiratime,nosuid,size=5G,mode=777 0 0" | sudo tee -a /etc/fstab
fi
mkdir -p $PATH_RAMDISK
#determine if ramdisk is in fstab
if [[ ! `mount | grep "$PATH_RAMDISK"` ]]; then
mount "$PATH_RAMDISK"
fi
if [ ! -d "$SQL_BACKUP" ]; then
mkdir $SQL_BACKUP
fi
if [ ! -h "$MYSQL_PATH/parts.frm" ]; then
cp $MYSQL_PATH/parts.frm $SQL_BACKUP/
mv $MYSQL_PATH/parts.frm $PATH_RAMDISK/
ln -s $PATH_RAMDISK/parts.frm $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/parts.MYD" ]; then
cp $MYSQL_PATH/parts.MYD $SQL_BACKUP/
mv $MYSQL_PATH/parts.MYD $PATH_RAMDISK/
ln -s $PATH_RAMDISK/parts.MYD $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/parts.MYI" ]; then
cp $MYSQL_PATH/parts.MYI $SQL_BACKUP/
mv $MYSQL_PATH/parts.MYI $PATH_RAMDISK/
ln -s $PATH_RAMDISK/parts.MYI $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/partrepair.frm" ]; then
cp $MYSQL_PATH/partrepair.frm $SQL_BACKUP/
mv $MYSQL_PATH/partrepair.frm $PATH_RAMDISK/
ln -s $PATH_RAMDISK/partrepair.frm $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/partrepair.MYD" ]; then
cp $MYSQL_PATH/partrepair.MYD $SQL_BACKUP/
mv $MYSQL_PATH/partrepair.MYD $PATH_RAMDISK/
ln -s $PATH_RAMDISK/partrepair.MYD $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/partrepair.MYI" ]; then
cp $MYSQL_PATH/partrepair.MYI $SQL_BACKUP/
mv $MYSQL_PATH/partrepair.MYI $PATH_RAMDISK/
ln -s $PATH_RAMDISK/partrepair.MYI $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/binaries.frm" ]; then
cp $MYSQL_PATH/binaries.frm $SQL_BACKUP/
mv $MYSQL_PATH/binaries.frm $PATH_RAMDISK/
ln -s $PATH_RAMDISK/binaries.frm $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/binaries.MYD" ]; then
cp $MYSQL_PATH/binaries.MYD $SQL_BACKUP/
mv $MYSQL_PATH/binaries.MYD $PATH_RAMDISK/
ln -s $PATH_RAMDISK/binaries.MYD $MYSQL_PATH/
fi
if [ ! -h "$MYSQL_PATH/binaries.MYI" ]; then
cp $MYSQL_PATH/binaries.MYI $SQL_BACKUP/
mv $MYSQL_PATH/binaries.MYI $PATH_RAMDISK/
ln -s $PATH_RAMDISK/binaries.MYI $MYSQL_PATH/
fi
chown -R $USER:$USER $SQL_BACKUP/
chown -R mysql:mysql $PATH_RAMDISK
chown -R mysql:mysql $MYSQL_PATH
/etc/init.d/mysql start
exit
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
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"
exit 1
fi
source $DIR/../defaults.sh
#edit this to allow script to run, be sure of the paths
#the ramdisk needs to be twice the size of the parts table max size, it needs room to copy itself during optimise
#i take no responsibility if this fails and you lose you db
#remove the next 2 lines when you have edited this file properlly
echo "Please edit this script, very carefully!"
exit
export PATH_RAMDISK="/var/ramdisk"
export MYSQL_PATH="/var/lib/mysql/newznab"
export SQL_BACKUP="/home/$USER/sql_backup"
/etc/init.d/mysql stop
if [ -h "$MYSQL_PATH/parts.frm" ]; then
rm $MYSQL_PATH/parts.frm
mv $PATH_RAMDISK/parts.frm $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/parts.MYD" ]; then
rm $MYSQL_PATH/parts.MYD
mv $PATH_RAMDISK/parts.MYD $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/parts.MYI" ]; then
rm $MYSQL_PATH/parts.MYI
mv $PATH_RAMDISK/parts.MYI $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/partrepair.frm" ]; then
rm $MYSQL_PATH/partrepair.frm
mv $PATH_RAMDISK/partrepair.frm $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/partrepair.MYD" ]; then
rm $MYSQL_PATH/partrepair.MYD
mv $PATH_RAMDISK/partrepair.MYD $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/partrepair.MYI" ]; then
rm $MYSQL_PATH/partrepair.MYI
mv $PATH_RAMDISK/partrepair.MYI $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/binaries.frm" ]; then
rm $MYSQL_PATH/binaries.frm
mv $PATH_RAMDISK/binaries.frm $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/binaries.MYD" ]; then
rm $MYSQL_PATH/binaries.MYD
mv $PATH_RAMDISK/binaries.MYD $MYSQL_PATH/
fi
if [ -h "$MYSQL_PATH/binaries.MYI" ]; then
rm $MYSQL_PATH/binaries.MYI
mv $PATH_RAMDISK/binaries.MYI $MYSQL_PATH/
fi
chown -R mysql:mysql $MYSQL_PATH
#determine if ramdisk is in fstab
if [[ `mount | grep "$PATH_RAMDISK"` ]]; then
umount "$PATH_RAMDISK"
fi
/etc/init.d/mysql start
exit