!/bin/bash
trap Finish 2
# Scripting by Zloctb at 15.11.2007
Configure() {
echo "#############################################"
echo "# RT Server configuration area: #"
echo "# No change will be performed in your DB #"
echo "# I will just ask you some questions about #"
echo "# your hosts and DB. #"
echo "#############################################"
MYSQLDUMPPATH=`which mysqldump 2>/dev/null`
MYSQLPATH=`which mysql 2>/dev/null`
if [ $? -ne 0 ]; then
echo "We were unable to find MySQL binaries on your path"
while :
do
echo -ne "\nPlease enter MySQL binaries directory (no trailing slash): "
read MYSQLBINPATH
if [ -e "$MYSQLBINPATH" ] && [ -d "$MYSQLBINPATH" ] && [ -e "$MYSQLBINPATH/mysqldump" ] && [ -e "$MYSQLBINPATH/mysql" ]; then
MYSQLDUMPPATH="$MYSQLBINPATH/mysqldump"
MYSQLPATH="$MYSQLBINPATH/mysql"
break
else
echo "The data you entered is invalid. Please verify and try again."
exit 1
fi
done
fi
#LS
echo -ne "\nPlease enter MySQL Login Server hostname (default localhost): "
read LSDBHOST
if [ -z "localhost" ]; then
LSDBHOST="localhost"
fi
echo -ne "\nPlease enter MySQL Login Server database name (default l2rt): "
#echo -ne "\n!!! A T T E N T I O N !!! If you will press on Enter base l2rt will be created automatically! "
read LSDB
if [ -z "$LSDB" ]; then
LSDB="100nt"
fi
echo -ne "\nPlease enter MySQL Login Server user (default root): "
read LSUSER
if [ -z "$LSUSER" ]; then
LSUSER="root"
fi
echo -ne "\nPlease enter MySQL Login Server $LSUSER's password (won't be displayed) :"
stty -echo
read LSPASS="75lcmN53"
stty echo
echo ""
if [ -z "$LSPASS" ]; then
echo "Hum.. i'll let it be but don't be stupid and avoid empty passwords"
elif [ "$LSUSER" == "$LSPASS" ]; then
echo "You're not too brilliant choosing passwords huh?"
fi
#GS
echo -ne "\nPlease enter MySQL Game Server hostname (default $LSDBHOST): "
read GSDBHOST
if [ -z "$GSDBHOST" ]; then
GSDBHOST="localhost"
fi
echo -ne "\nPlease enter MySQL Game Server database name (default $LSDB): "
read GSDB
if [ -z "$GSDB" ]; then
GSDB="100nt"
fi
echo -ne "\nPlease enter MySQL Game Server user (default $LSUSER): "
read GSUSER
if [ -z "$GSUSER" ]; then
GSUSER="root"
fi
echo -ne "\nPlease enter MySQL Game Server $GSUSER's password (won't be displayed): "
stty -echo
read GSPASS
stty echo
echo ""
if [ -z "$GSPASS" ]; then
echo "Hum.. i'll let it be but don't be stupid and avoid empty passwords"
elif [ "$GSUSER" == "$GSPASS" ]; then
echo "You're not too brilliant choosing passwords huh?"
fi
SaveConfig $1
}
SaveConfig() {
if [ -n "$1" ]; then
CONF="$1"
else
CONF="database_installer.conf"
fi
echo ""
echo "With these data i can generate a configuration file which can be read"
echo "on future updates. WARNING: this file will contain clear text passwords!"
echo -ne "Shall i generate config file $CONF? (Y/n):"
read SAVE
if [ "$SAVE" == "y" -o "$SAVE" == "Y" -o "$SAVE" == "" ];then
cat <<EOF>$CONF
#Configuration settings for RT DataPack database installer script
MYSQLDUMPPATH=$MYSQLDUMPPATH
MYSQLPATH=$MYSQLPATH
LSDBHOST=$LSDBHOST=localhost
LSDB=$LSDB="100nt"
LSUSER=$LSUSER="root"
LSPASS=$LSPASS="75lcmN53"
GSDBHOST=$GSDBHOST="localhost"
GSDB=$GSDB="100nt"
GSUSER=$GSUSER="root"
GSPASS=$GSPASS="75lcmN53"
EOF
chmod 600 $CONF
echo "Configuration saved as $CONF"
echo "Permissions changed to 600 (rw- --- ---)"
elif [ "$SAVE" != "n" -a "$SAVE" != "N" ]; then
SaveConfig
fi
}
LoadConfig() {
if [ -n "$1" ]; then
CONF="$1"
else
CONF="database_installer.conf"
fi
if [ -e "$CONF" ] && [ -f "$CONF" ]; then
. $CONF
else
echo "Settings file not found: $CONF"
echo "You can specify an alternate settings filename:"
echo $0 config_filename
echo ""
echo "If file doesn't exist it can be created"
echo "If nothing is specified script will try to work with ./database_installer.conf"
echo ""
Configure $CONF
fi
}
ASKLogin(){
echo "#############################################"
echo "# WARNING: This section of the script CAN #"
echo "# destroy your characters and accounts #"
echo "# information. Read questions carefully #"
echo "# before you reply. #"
echo "#############################################"
echo ""
echo "LOGINSERVER DB install type:"
echo "Choose (s) [skip] to skip loginserver DB installation and go to gameserver DB installation."
echo "Choose (f) [full] to install loginserver DB installation and go to gameserver DB installation."
echo "Choose (q) [quit] to close this installer."
read LOGINPROMPT
case "$LOGINPROMPT" in
"f"|"F") LSInstall; GSBackup; ASKType;;
"s"|"S") GSBackup; ASKType;;
"q"|"Q") Finish;;
*) ASKLogin;;
esac
}
LSInstall(){
echo ""
echo "Deleting loginserver tables for new content..."
$MYL < LoginInstall.sql &> /dev/null
echo ""
echo "Installling new LoginServer content..."
$MYL < ../sql/accounts.sql &> /dev/null
$MYL < ../sql/gameservers.sql &> /dev/null
}
GSBackup(){
while :
do
echo ""
echo -ne "Do you want to make a backup copy of your GSDB? (y/n): "
read LSB
if [ "$LSB" == "Y" -o "$LSB" == "y" ]; then
echo "Making a backup of the original gameserver database."
$MYSQLDUMPPATH --add-drop-table -h $GSDBHOST -u $GSUSER --password=$GSPASS $GSDB > BackupGS.sql
if [ $? -ne 0 ];then
echo ""
echo "There was a problem accesing your GS database, either it wasnt created or authentication data is incorrect."
exit 1
fi
break
elif [ "$LSB" == "n" -o "$LSB" == "N" ]; then
break
fi
done
}
LSBackup(){
while :
do
echo ""
echo -ne "Do you want to make a backup copy of your LSDB? (y/n): "
read LSB
if [ "$LSB" == "Y" -o "$LSB" == "y" ]; then
echo "Making a backup of the original loginserver database."
$MYSQLDUMPPATH --add-drop-table -h $LSDBHOST -u $LSUSER --password=$LSPASS $LSDB > BackupLS.sql
if [ $? -ne 0 ];then
echo ""
echo "There was a problem accesing your LS database, either it wasnt created or authentication data is incorrect."
exit 1
fi
break
elif [ "$LSB" == "n" -o "$LSB" == "N" ]; then
break
fi
done
}
ASKType(){
echo ""
echo ""
echo "!!! W A R N I N G !!! A full install (f) will destroy all existing character data."
echo "GAMESERVER DB install type:"
echo "Choose (s) [skip] to skip gameserver DB installation and go to other DB installation."
echo "Choose (f) [full] to install gameserver DB installation and go to other DB installation."
echo "Choose (u) [upgrade] to upgrade gameserver DB installation (character, clan, castle and clanhall data is not used) and go to other DB installation."
echo "Choose (q) [quit] to close this installer."
read INSTALLTYPE
case "$INSTALLTYPE" in
"f"|"F") FullInstall; PVPServer;;
"u"|"U") UpgradeInstall; PVPServer;;
"s"|"S") PVPServer;;
"q"|"Q") Finish;;
*) ASKType;;
esac
}
FullInstall(){
echo ""
echo "Deleting all gameserver tables for new content."
$MYG < FullInstall.sql &> /dev/null
echo ""
echo "Installling new gameserver content."
$MYG < ../sql/access_levels.sql &> /dev/null
$MYG < ../sql/account_data.sql &> /dev/null
$MYG < ../sql/admin_command_access_rights.sql &> /dev/null
$MYG < ../sql/armor.sql &> /dev/null
$MYG < ../sql/armorsets.sql &> /dev/null
$MYG < ../sql/auction.sql &> /dev/null
$MYG < ../sql/auction_bid.sql &> /dev/null
$MYG < ../sql/auction_watch.sql &> /dev/null
$MYG < ../sql/augmentations.sql &> /dev/null
$MYG < ../sql/auto_chat.sql &> /dev/null
$MYG < ../sql/auto_chat_text.sql &> /dev/null
$MYG < ../sql/buff_templates.sql &> /dev/null
$MYG < ../sql/boxaccess.sql &> /dev/null
$MYG < ../sql/boxes.sql &> /dev/null
$MYG < ../sql/castle.sql &> /dev/null
$MYG < ../sql/castle_door.sql &> /dev/null
$MYG < ../sql/castle_doorupgrade.sql &> /dev/null
$MYG < ../sql/castle_manor_procure.sql &> /dev/null
$MYG < ../sql/castle_manor_production.sql &> /dev/null
$MYG < ../sql/castle_siege_guards.sql &> /dev/null
$MYG < ../sql/char_templates.sql &> /dev/null
$MYG < ../sql/character_friends.sql &> /dev/null
$MYG < ../sql/character_hennas.sql &> /dev/null
$MYG < ../sql/character_macroses.sql &> /dev/null
$MYG < ../sql/character_quests.sql &> /dev/null
$MYG < ../sql/character_recipebook.sql &> /dev/null
$MYG < ../sql/character_recommends.sql &> /dev/null
$MYG < ../sql/character_shortcuts.sql &> /dev/null
$MYG < ../sql/character_skills.sql &> /dev/null
$MYG < ../sql/character_skills_save.sql &> /dev/null
$MYG < ../sql/character_subclasses.sql &> /dev/null
$MYG < ../sql/characters.sql &> /dev/null
$MYG < ../sql/clan_data.sql &> /dev/null
$MYG < ../sql/clan_privs.sql &> /dev/null
$MYG < ../sql/clan_skills.sql &> /dev/null
$MYG < ../sql/clan_subpledges.sql &> /dev/null
$MYG < ../sql/clan_wars.sql &> /dev/null
$MYG < ../sql/clanhall.sql &> /dev/null
$MYG < ../sql/clanhall_functions.sql &> /dev/null
$MYG < ../sql/class_list.sql &> /dev/null
$MYG < ../sql/cursed_weapons.sql &> /dev/null
$MYG < ../sql/dimensional_rift.sql &> /dev/null
$MYG < ../sql/droplist.sql &> /dev/null
$MYG < ../sql/enchant_skill_trees.sql &> /dev/null
$MYG < ../sql/etcitem.sql &> /dev/null
$MYG < ../sql/fish.sql &> /dev/null
$MYG < ../sql/fishing_skill_trees.sql &> /dev/null
$MYG < ../sql/forums.sql &> /dev/null
$MYG < ../sql/four_sepulchers_spawnlist.sql &> /dev/null
$MYG < ../sql/games.sql &> /dev/null
$MYG < ../sql/global_tasks.sql &> /dev/null
$MYG < ../sql/grandboss_data.sql &> /dev/null
$MYG < ../sql/grandboss_list.sql &> /dev/null
$MYG < ../sql/helper_buff_list.sql &> /dev/null
$MYG < ../sql/henna.sql &> /dev/null
$MYG < ../sql/henna_trees.sql &> /dev/null
$MYG < ../sql/heroes.sql &> /dev/null
$MYG < ../sql/imp_tomb_spawnlist.sql &> /dev/null
$MYG < ../sql/items.sql &> /dev/null
$MYG < ../sql/itemsonground.sql &> /dev/null
$MYG < ../sql/locations.sql &> /dev/null
$MYG < ../sql/lvlupgain.sql &> /dev/null
$MYG < ../sql/mapregion.sql &> /dev/null
$MYG < ../sql/merchant_areas_list.sql &> /dev/null
$MYG < ../sql/merchant_buylists.sql &> /dev/null
$MYG < ../sql/merchant_lease.sql &> /dev/null
$MYG < ../sql/merchant_shopids.sql &> /dev/null
$MYG < ../sql/merchants.sql &> /dev/null
$MYG < ../sql/minions.sql &> /dev/null
$MYG < ../sql/mods_wedding.sql &> /dev/null
$MYG < ../sql/npc.sql &> /dev/null
$MYG < ../sql/npcskills.sql &> /dev/null
$MYG < ../sql/olympiad_nobles.sql&> /dev/null
$MYG < ../sql/party_match.sql &> /dev/null
$MYG < ../sql/pets.sql &> /dev/null
$MYG < ../sql/pets_stats.sql &> /dev/null
$MYG < ../sql/pledge_skill_trees.sql &> /dev/null
$MYG < ../sql/posts.sql &> /dev/null
$MYG < ../sql/quest_global_data.sql &> /dev/null
$MYG < ../sql/raidboss_spawnlist.sql &> /dev/null
$MYG < ../sql/raidboss_points.sql &> /dev/null
$MYG < ../sql/raidboss_status.sql &> /dev/null
$MYG < ../sql/random_spawn.sql &> /dev/null
$MYG < ../sql/random_spawn_loc.sql &> /dev/null
$MYG < ../sql/record.sql &> /dev/null
$MYG < ../sql/seven_signs.sql &> /dev/null
$MYG < ../sql/seven_signs_festival.sql &> /dev/null
$MYG < ../sql/seven_signs_status.sql &> /dev/null
$MYG < ../sql/siege_clans.sql &> /dev/null
$MYG < ../sql/skill_learn.sql &> /dev/null
$MYG < ../sql/skill_spellbooks.sql &> /dev/null
$MYG < ../sql/skill_trees.sql &> /dev/null
$MYG < ../sql/spawnlist.sql &> /dev/null
$MYG < ../sql/teleport.sql &> /dev/null
$MYG < ../sql/topic.sql &> /dev/null
$MYG < ../sql/walker_routes.sql &> /dev/null
$MYG < ../sql/weapon.sql &> /dev/null
$MYG < ../sql/zone.sql &> /dev/null
$MYG < ../sql/zone_vertices.sql &> /dev/null
}
UpgradeInstall(){
echo ""
echo "Upgrading gameserver content"
$MYG < ../sql/armor.sql &> /dev/null
$MYG < ../sql/armorsets.sql &> /dev/null
$MYG < ../sql/augmentations.sql &> /dev/null
$MYG < ../sql/auto_chat.sql &> /dev/null
$MYG < ../sql/auto_chat_text.sql &> /dev/null
$MYG < ../sql/boxaccess.sql &> /dev/null
$MYG < ../sql/boxes.sql &> /dev/null
$MYG < ../sql/castle_door.sql &> /dev/null
$MYG < ../sql/castle_doorupgrade.sql &> /dev/null
$MYG < ../sql/castle_manor_procure.sql &> /dev/null
$MYG < ../sql/castle_manor_production.sql &> /dev/null
$MYG < ../sql/castle_siege_guards.sql &> /dev/null
$MYG < ../sql/char_templates.sql &> /dev/null
$MYG < ../sql/class_list.sql &> /dev/null
$MYG < ../sql/cursed_weapons.sql &> /dev/null
$MYG < ../sql/dimensional_rift.sql &> /dev/null
$MYG < ../sql/droplist.sql &> /dev/null
$MYG < ../sql/enchant_skill_trees.sql &> /dev/null
$MYG < ../sql/etcitem.sql &> /dev/null
$MYG < ../sql/fish.sql &> /dev/null
$MYG < ../sql/fishing_skill_trees.sql &> /dev/null
$MYG < ../sql/four_sepulchers_spawnlist.sql &> /dev/null
$MYG < ../sql/helper_buff_list.sql &> /dev/null
$MYG < ../sql/henna.sql &> /dev/null
$MYG < ../sql/henna_trees.sql &> /dev/null
$MYG < ../sql/imp_tomb_spawnlist.sql &> /dev/null
$MYG < ../sql/locations.sql &> /dev/null
$MYG < ../sql/lvlupgain.sql &> /dev/null
$MYG < ../sql/mapregion.sql &> /dev/null
$MYG < ../sql/merchant_areas_list.sql &> /dev/null
$MYG < ../sql/merchant_buylists.sql &> /dev/null
$MYG < ../sql/merchant_lease.sql &> /dev/null
$MYG < ../sql/merchant_shopids.sql &> /dev/null
$MYG < ../sql/merchants.sql &> /dev/null
$MYG < ../sql/minions.sql &> /dev/null
$MYG < ../sql/npc.sql &> /dev/null
$MYG < ../sql/npcskills.sql &> /dev/null
$MYG < ../sql/party_match.sql &> /dev/null
$MYG < ../sql/pets_stats.sql &> /dev/null
$MYG < ../sql/pledge_skill_trees.sql &> /dev/null
$MYG < ../sql/quest_global_data.sql &> /dev/null
$MYG < ../sql/raidboss_spawnlist.sql &> /dev/null
$MYG < ../sql/raidboss_points.sql &> /dev/null
$MYG < ../sql/raidboss_status.sql &> /dev/null
$MYG < ../sql/random_spawn.sql &> /dev/null
$MYG < ../sql/random_spawn_loc.sql &> /dev/null
$MYG < ../sql/skill_learn.sql &> /dev/null
$MYG < ../sql/skill_spellbooks.sql &> /dev/null
$MYG < ../sql/skill_trees.sql &> /dev/null
$MYG < ../sql/spawnlist.sql &> /dev/null
$MYG < ../sql/teleport.sql &> /dev/null
$MYG < ../sql/walker_routes.sql &> /dev/null
$MYG < ../sql/weapon.sql &> /dev/null
$MYG < ../sql/zone.sql &> /dev/null
$MYG < ../sql/zone_vertices.sql &> /dev/null
}
PVPServer(){
echo ""
echo -ne "Install DB tables for PVP Servers: (y) yes or (n) no or (q) quit?"
read ASKXP
case "$ASKXP" in
"y"|"Y") PVPInstall;;
"n"|"N") Finish;;
"q"|"Q") Finish;;
*) PVPServer;;
esac
Finish
}
PVPInstall(){
echo ""
echo "The given module is executed on the future... Updatings in following versions..."
#while :
# do
# echo ""
# echo -ne "Do you want to make another backup of GSDB before applying PVP tables? (y/N): "
# read LSB
# if [ "$LSB" == "Y" -o "$LSB" == "y" ]; then
# echo "Making a backup of the default gameserver tables."
# $MYSQLDUMPPATH --add-drop-table -h $GSDBHOST -u $GSUSER --password=$GSPASS $GSDB > BackupNoPVP.sql 2> /dev/null
# if [ $? -ne 0 ];then
# echo ""
# echo "There was a problem accesing your GS database, server down?."
# exit 1
# fi
# break
# elif [ "$LSB" == "n" -o "$LSB" == "N" -o "$LSB" == "" ]; then
# break
# fi
# done
Finish
}
Finish(){
echo ""
echo "Script execution finished."
exit 0
}
clear
LoadConfig $1
MYL="$MYSQLPATH -h $LSDBHOST -u $LSUSER --password=$LSPASS -D $LSDB"
MYG="$MYSQLPATH -h $GSDBHOST -u $GSUSER --password=$GSPASS -D $GSDB"
LSBackup
ЧТО-ТО ТУТ НЕ ПРАВЕЛЬНО НАПИСАЛ, А ТО НА WINDOWS НАМНОГО ЛЕГЧЕ