summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-11-05 19:31:08 +0100
committerHaru <haru@dotalux.com>2013-11-05 19:35:27 +0100
commit285296a2c748533a85d07589687f6ccdc2d94613 (patch)
tree9f32b736ed7b1cea6356932627de04445d4f0974
parent97001710c06ed7053d18c8baaac602eb563b64b3 (diff)
downloadhercules-285296a2c748533a85d07589687f6ccdc2d94613.tar.gz
hercules-285296a2c748533a85d07589687f6ccdc2d94613.tar.bz2
hercules-285296a2c748533a85d07589687f6ccdc2d94613.tar.xz
hercules-285296a2c748533a85d07589687f6ccdc2d94613.zip
Follow-up to 97001710c06ed7053d18c8baaac602eb563b64b3
- Added missing license note and error message to the script-checker bash script - Added Script-Checker.applescript. Open in Applescript Editor and save as .app bundle in order to use it. It's not pretty, but it works. Signed-off-by: Haru <haru@dotalux.com>
-rwxr-xr-xscript-checker7
-rw-r--r--tools/Script-Checker.applescript151
2 files changed, 158 insertions, 0 deletions
diff --git a/script-checker b/script-checker
index ec79fcc61..521cf9025 100755
--- a/script-checker
+++ b/script-checker
@@ -1,11 +1,18 @@
#!/bin/bash
+# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+# See the LICENSE file
+# Base Author: Haru @ http://hercules.ws
+
ORIG_CWD="$(pwd)"
BASEDIR="$(dirname "$0")"
EXECUTABLE="./map-server"
cd "${BASEDIR}"
if [ -z "$1" ]; then
+ echo "No file specified."
+ echo "Usage: $0 <path to the script>"
+ echo " (you may use a relative or absolute path)"
exit -1
elif [[ "$1" =~ ^\/ ]]; then
FILE="$1"
diff --git a/tools/Script-Checker.applescript b/tools/Script-Checker.applescript
new file mode 100644
index 000000000..db1983f4b
--- /dev/null
+++ b/tools/Script-Checker.applescript
@@ -0,0 +1,151 @@
+(*
+ Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+ See the LICENSE file
+ Base Author: Haru @ http://hercules.ws
+*)
+
+(*
+ *************************************************************
+ *************************************************************
+ ******** **************
+ ******** NOTE: This script must be saved as app!!! **************
+ ******** **************
+ *************************************************************
+ *************************************************************
+*)
+
+property allowed_extensions : {"txt", "c", "ath", "herc"}
+property allowed_types : {"TEXT"}
+
+on run
+ try
+ set the resource_path to path to resource "Scripts"
+ tell application "Finder" to set the resource_path to the container of the resource_path
+ on error
+ display alert "Error" message "You need to save this script as an app bundle." buttons {"Cancel"} cancel button 1 as warning
+ end try
+ set the dialog_result to display dialog "You can drag files to this app to have them checked." with title "Hercules Script Checker" buttons {"Cancel", "(Re)build Hercules", "Check Script"} default button 3 cancel button 1
+ if the button returned of the dialog_result is "(Re)build Hercules" then
+ rebuild()
+ else
+ set these_items to choose file of type allowed_extensions with prompt "Choose the script(s) you want to check:" with multiple selections allowed
+ process_items(these_items)
+ end if
+end run
+
+on open these_items
+ process_items(these_items)
+end open
+
+on build_hercules(hercules_repo)
+ try
+ set the resource_path to path to resource "Scripts"
+ tell application "Finder" to set the resource_path to the container of the resource_path
+ on error
+ display alert "Error" message "You need to save this script as an app bundle." buttons {"Cancel"} cancel button 1 as warning
+ end try
+ set the configuration_flags to display dialog "Do you want to use any configuration flags? (i.e. --disable-renewal)" with title "Configuration" default answer "" buttons {"Cancel", "Ok"} default button 2 cancel button 1
+ try
+ set the command_output to do shell script "cd " & (the quoted form of the POSIX path of the hercules_repo) & " && echo './configure " & the text returned of the configuration_flags & " 2>&1' | bash -i"
+ on error
+ display dialog "Configuration failed" with title "Configuration result" buttons {"Abort"} cancel button 1
+ end try
+ tell application "TextEdit"
+ activate
+ set the new_document to make new document
+ set the text of new_document to the command_output
+ end tell
+ display dialog "Configuration successfully completed. Please check the log file for details." with title "Configuration result" buttons {"Abort", "Continue"} default button 2 cancel button 1
+ try
+ set the command_output to do shell script "cd " & (the quoted form of the POSIX path of the hercules_repo) & " && echo 'make clean 2>&1 && make sql -j8 2>&1' | bash -i"
+ on error
+ display dialog "Build failed." with title "Build result" buttons {"Abort"} cancel button 1
+ end try
+ tell application "TextEdit"
+ activate
+ set the new_document to make new document
+ set the text of new_document to the command_output
+ end tell
+ display dialog "Build successfully completed. Please check the log file for details." with title "Build result" buttons {"Abort", "Continue"} default button 2 cancel button 1
+ set the files_to_copy to {"map-server", "script-checker"}
+ set the conf_files_to_copy to {"inter-server.conf", "import", "packet.conf", "script.conf"}
+ set the db_files_to_copy to {"map_index.txt", "item_db2.txt", "const.txt", "mob_db2.txt"}
+ set the db2_files_to_copy to {"map_cache.dat", "item_db.txt", "skill_db.txt", "mob_db.txt"}
+ try
+ set the hercules_path to path to resource "Hercules"
+ do shell script "rm -r " & the quoted form of ((the POSIX path of hercules_path) & "/")
+ end try
+ set the hercules_path to the resource_path
+ tell application "Finder" to make new folder at hercules_path with properties {name:"Hercules"}
+ delay 3
+ set the hercules_path to path to resource "Hercules"
+ repeat with each_file in files_to_copy
+ copy_file(each_file, hercules_repo, hercules_path, ".")
+ end repeat
+ do shell script "mkdir " & the quoted form of ((POSIX path of the hercules_path) & "/conf")
+ repeat with each_file in conf_files_to_copy
+ copy_file(each_file, hercules_repo, hercules_path, "conf")
+ end repeat
+ do shell script "mkdir " & the quoted form of ((POSIX path of the hercules_path) & "/db")
+ repeat with each_file in db_files_to_copy
+ copy_file(each_file, hercules_repo, hercules_path, "db")
+ end repeat
+ do shell script "mkdir " & the quoted form of ((POSIX path of the hercules_path) & "/db/pre-re")
+ repeat with each_file in db2_files_to_copy
+ copy_file(each_file, hercules_repo, hercules_path, "db/pre-re")
+ end repeat
+ do shell script "mkdir " & the quoted form of ((POSIX path of the hercules_path) & "/db/re")
+ repeat with each_file in db2_files_to_copy
+ copy_file(each_file, hercules_repo, hercules_path, "db/re")
+ end repeat
+ display dialog "Build complete" with title "Done" buttons {"Ok"} default button "Ok"
+end build_hercules
+
+on rebuild()
+ set the repo_path to choose folder with prompt "Choose the folder where your Hercules repository is located:"
+ build_hercules(repo_path)
+end rebuild
+
+on copy_file(filename, source, destination, subpath)
+ do shell script "cp -rp " & the quoted form of ((the POSIX path of source) & "/" & subpath & "/" & filename) & " " & the quoted form of ((the POSIX path of destination) & "/" & subpath & "/")
+end copy_file
+
+on process_items(these_items)
+ repeat
+ try
+ set the scriptchecker to the path to resource "script-checker" in directory "Hercules"
+ set the mapserver to the path to resource "map-server" in directory "Hercules"
+ on error
+ display alert "Missing Hercules binaries" message "You need to build Hercules and place it within this app bundle before running the script checker." & linefeed & linefeed & "I can try to build it for you, but only if you have the Xcode command line tools installed." & linefeed & "Do you want to continue?" buttons {"Cancel", "Build"} default button "Build" cancel button "Cancel" as warning
+ rebuild()
+ return false
+ end try
+ exit repeat
+ end repeat
+ repeat with i from 1 to the count of these_items
+ set this_item to item i of these_items
+ set the item_info to info for this_item
+ set this_name to the name of the item_info
+ try
+ set this_extension to the name extension of item_info
+ on error
+ set this_extension to ""
+ end try
+ try
+ set this_filetype to the file type of item_info
+ on error
+ set this_filetype to ""
+ end try
+ if (folder of the item_info is false) and (alias of the item_info is false) and ((this_filetype is in the allowed_types) or (this_extension is in the allowed_extensions)) then
+ process_item(scriptchecker, this_item)
+ end if
+ end repeat
+end process_items
+
+on process_item(checkerpath, this_item)
+ set the_result to do shell script (the quoted form of the POSIX path of checkerpath & " " & the quoted form of the POSIX path of this_item) & " 2>&1"
+ if the_result is "" then
+ set the_result to "Check passed."
+ end if
+ display dialog ("File: " & POSIX path of this_item) & linefeed & "Result: " & linefeed & the_result with title "Output" buttons {"Abort", "Next"} default button "Next" cancel button "Abort"
+end process_item