*) added skript to change memory settings, password and port (experimental, don't blame me if it messes up your configuration)
*) minor change in Digest class, added option in main method, might not be optimal yet git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6450 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
11f7da06ed
commit
f1740edbf8
@ -0,0 +1,250 @@
|
||||
#!/bin/sh
|
||||
|
||||
# THIS SCRIPT CAN BE USED TO EDIT SOME BASIC SETTINGS OF YACY
|
||||
#
|
||||
# Copyright 2009 by Marc Nause; marc.nause@gmx.de
|
||||
#
|
||||
# This is a part of YaCy, a peer-to-peer based web search engine.
|
||||
# http://www.yacy.net
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $LastChangedRevision$
|
||||
# $LastChangedBy$
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#
|
||||
# DEFINING SOME CONSTANTS
|
||||
#
|
||||
DATADIR="DATA"
|
||||
SETTINGSDIR="DATA/SETTINGS"
|
||||
CONFIGFILE="DATA/SETTINGS/yacy.conf"
|
||||
CONFIGTEMPLATE="defaults/yacy.init"
|
||||
LOCKFILE="DATA/yacy.running"
|
||||
JAVA="`which java`"
|
||||
|
||||
#
|
||||
# DEFINING SOME FUNCIONS WHICH WILL BE USED LATER
|
||||
#
|
||||
|
||||
# CHANGES THE ADMIN SETTINGS
|
||||
change_admin_settings()
|
||||
{
|
||||
change_admin_localhost
|
||||
}
|
||||
|
||||
change_admin_localhost()
|
||||
{
|
||||
echo
|
||||
echo -n 'Allow admin access for all local users (y/n)? '
|
||||
read INPUT
|
||||
case $INPUT in
|
||||
y)
|
||||
replace_parameter 'adminAccountForLocalhost' 'true'
|
||||
replace_parameter 'adminAccountBase64MD5' ''
|
||||
confirm
|
||||
;;
|
||||
n)
|
||||
replace_parameter 'adminAccountForLocalhost' 'false'
|
||||
confirm
|
||||
change_admin_password
|
||||
;;
|
||||
*)
|
||||
change_admin_localhost
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# CHANGES THE ADMIN PASSWORD
|
||||
change_admin_password()
|
||||
{
|
||||
echo -n 'Enter username (leave empty for standard username "admin"): '
|
||||
read USERNAME
|
||||
if [ "$USERNAME" == '' ]
|
||||
then
|
||||
USERNAME='admin';
|
||||
fi
|
||||
echo -n 'Enter new password (will not be displayed): '
|
||||
read -s INPUT1
|
||||
echo
|
||||
echo -n 'Enter new password again (will not be displayed): '
|
||||
read -s INPUT2
|
||||
echo
|
||||
|
||||
if [ $INPUT1 == $INPUT2 ]
|
||||
then
|
||||
BASE64=`$JAVA -cp classes net/yacy/kelondro/order/Base64Order -es "$USERNAME:$INPUT1"`
|
||||
B64MD5=`$JAVA -cp classes net/yacy/kelondro/order/Digest -strfhex "$BASE64"`
|
||||
B64MD5=`echo $B64MD5 | sed "s/\(\S\) .*/\1/"`
|
||||
replace_parameter 'adminAccountBase64MD5' "$B64MD5"
|
||||
else
|
||||
echo 'Entries did not match, please try again.'
|
||||
change_admin_password
|
||||
fi
|
||||
confirm
|
||||
|
||||
}
|
||||
|
||||
# CHANGES THE MEMORY SETTINGS
|
||||
change_mem_settings()
|
||||
{
|
||||
echo
|
||||
echo -n 'How much memory (in MB) do you want YaCy to be able to use? '
|
||||
read INPUT
|
||||
|
||||
case $INPUT in
|
||||
*[0-9]*)
|
||||
replace_parameter 'javastart_Xmx' "Xmx$INPUT"'m'
|
||||
replace_parameter 'javastart_Xms' "Xms$INPUT"'m'
|
||||
;;
|
||||
*)
|
||||
echo 'Please enter a number.'
|
||||
change_mem_settings
|
||||
;;
|
||||
esac
|
||||
confirm
|
||||
}
|
||||
|
||||
# CHANGES THE PORT SETTINGS
|
||||
change_port_settings()
|
||||
{
|
||||
echo
|
||||
echo -n 'Which port do you want YaCy to use (standard is 8080)? '
|
||||
read INPUT
|
||||
|
||||
|
||||
if [ "$INPUT" == '' ]
|
||||
then
|
||||
INPUT='8080'
|
||||
fi
|
||||
|
||||
case $INPUT in
|
||||
*[0-9]*)
|
||||
replace_parameter 'port' $INPUT
|
||||
;;
|
||||
*)
|
||||
echo 'Please enter a number.'
|
||||
change_port_settings
|
||||
;;
|
||||
esac
|
||||
confirm
|
||||
}
|
||||
|
||||
# CHECKS IF CONFIG FILE EXISTS, EXISTS IF IT DOESN'T
|
||||
check_conf()
|
||||
{
|
||||
if [ ! -e "$CONFIGFILE" ]
|
||||
then
|
||||
echo
|
||||
echo "Config file does not exist. Please start YaCy at least once to create config file."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# CHECKS IF A STANDARD JVM HAS BEEN SET, EXITS IF NOT
|
||||
check_java()
|
||||
{
|
||||
if [ "$JAVA" == '' ]
|
||||
then
|
||||
echo
|
||||
echo "Java has not been detected. Please add java to your classpath."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# EXITS WITH WARNING IF LOCKFILE EXISTS
|
||||
check_lock()
|
||||
{
|
||||
if [ -f "$LOCKFILE" ]
|
||||
then
|
||||
echo "WARNING:"
|
||||
echo "$LOCKFILE exists which indicates that YaCy is still running."
|
||||
echo "Please stop YaCy before running this script."
|
||||
echo "If you are sure that YaCy is not running anymore,"
|
||||
echo "delete $LOCKFILE and start this script again."
|
||||
echo
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# WRITES A MESSAGE OF CONFIRMATION
|
||||
confirm()
|
||||
{
|
||||
echo 'Changes have been written to the config file.'
|
||||
}
|
||||
|
||||
# EXITS SRIPT AND PRINTS GOODBYE MESSAGE
|
||||
goodbye()
|
||||
{
|
||||
echo
|
||||
echo "Goodbye!"
|
||||
echo
|
||||
exit
|
||||
}
|
||||
|
||||
# PRINTS THE MENU
|
||||
print_menu()
|
||||
{
|
||||
echo
|
||||
echo "Make your choice:"
|
||||
echo "[1] change memory settings"
|
||||
echo "[2] change admin password"
|
||||
echo "[3] change port"
|
||||
echo "[0] quit"
|
||||
}
|
||||
|
||||
# REPLACES THE VALUE OF A PARAMETER (FIRST ARGUMENT) WITH A NEW ONE (SECOND ARGUMENT)
|
||||
replace_parameter()
|
||||
{
|
||||
sed "s/^\($1 *=\)\(.*\)/\1$2/" "$CONFIGFILE" >"$SETTINGSDIR/yacy.tmp"
|
||||
mv "$SETTINGSDIR/yacy.tmp" "$CONFIGFILE"
|
||||
}
|
||||
|
||||
#
|
||||
# MAIN PROGRAM
|
||||
#
|
||||
echo
|
||||
echo "*** YaCy commandline administration tool ***"
|
||||
|
||||
check_lock
|
||||
|
||||
check_conf
|
||||
|
||||
print_menu
|
||||
|
||||
while read -s -n1 INPUT
|
||||
do
|
||||
case $INPUT in
|
||||
0)
|
||||
goodbye
|
||||
;;
|
||||
1)
|
||||
change_mem_settings
|
||||
;;
|
||||
2)
|
||||
change_admin_settings
|
||||
;;
|
||||
3)
|
||||
change_port_settings
|
||||
;;
|
||||
esac
|
||||
print_menu
|
||||
done
|
||||
|
||||
#EOF
|
Loading…
Reference in new issue