diff --git a/README.md b/README.md index 2248bb1..ad06bbd 100644 --- a/README.md +++ b/README.md @@ -27,34 +27,7 @@ wsl --install -d Debian ``` -2. Once Installed, Export the a backup to the desired location: - ```cmd - wsl --export Debian C:\Example - ``` - or - ```cmd - wsl --export Debian D:\Example - ``` - -3. Unregister the Original Debian Image from WSL: - ```cmd - wsl --unregister Debian - ``` - -4. Import it back into your chosen location: - ```cmd - wsl --import Debian C:\Debian C:\Example\Debian.tar --version 2 - ``` - or - ```cmd - wsl --import Debian D:\Debian D:\Example\Debian.tar --version 2 - ``` - - - (Optional) Delete the .tar file to free space: - ```cmd - Remove-Item D:\Example\Debian.tar - ``` -5. Launch Debian: +2. Launch Debian: ```cmd wsl -d Debian ``` @@ -78,21 +51,7 @@ 4. run the sh file: ```cmd - ./setup-docker-wsl.sh - ``` - - - (!Note) If you run the script but with error, This usually means Windows-style line endings instead of the Unix-style. - To fix this run this command - ```cmd - sudo apt install dos2unix - - #then - - dos2unix *.sh - - #final command - - chmod +x *.sh + ./docker.sh ``` 5. wait until done then restart wsl: @@ -156,7 +115,7 @@ Includes: 7. Edit your `\Data\enUS\realmlist.wtf` and type in the wsl ip address you get in the end of installing. ``` -set realmlist 172.17.0.1 +set realmlist docker_ip ``` 8. Run the Game and your done. diff --git a/docker.sh b/docker.sh new file mode 100644 index 0000000..3ed4f04 --- /dev/null +++ b/docker.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e +set -o pipefail + +echo "[*] Updating system..." +sudo apt-get update && sudo apt-get dist-upgrade -y + +echo "[*] Installing base packages..." +sudo apt-get install -y ca-certificates curl wget gnupg lsb-release apt-transport-https + +# Only install genie if not already present +if ! command -v genie &> /dev/null; then + echo "[*] Setting up WSL genie (if running in WSL)..." + sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg + sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg + + echo -e "deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main\n\ +deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main" | \ + sudo tee /etc/apt/sources.list.d/wsl-transdebian.list > /dev/null + + sudo apt-get update + sudo apt-get install -y systemd-genie + + echo 'genie -i' >> ~/.bashrc +else + echo "✔️ Genie already installed." +fi + +# Docker check and install if not already installed +if ! command -v docker &> /dev/null; then + echo "[*] Docker not found. Installing Docker..." + + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ + https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + sudo usermod -aG docker $USER + + echo "✔️ Docker installed. Please log out and back in to apply group changes." + exit 1 +else + echo "✔️ Docker is already installed." +fi + +# Optional: Install docker-compose if not present +if ! command -v docker-compose &> /dev/null; then + echo "[*] Installing docker-compose..." + sudo curl -L "https://github.com/docker/compose/releases/download/2.32.4/docker-compose-$(uname -s)-$(uname -m)" \ + -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose +else + echo "✔️ docker-compose is already installed." +fi + +echo "✅ System preparation complete." diff --git a/start_stop_acore.sh b/instance.sh similarity index 100% rename from start_stop_acore.sh rename to instance.sh diff --git a/setup-docker-wsl.sh b/setup-docker-wsl.sh deleted file mode 100644 index 2dfb04d..0000000 --- a/setup-docker-wsl.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -sudo apt-get update -sudo apt-get dist-upgrade -sudo apt-get install ca-certificates curl wget gnupg lsb-release apt-transport-https - -wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb -sudo dpkg -i /tmp/packages-microsoft-prod.deb -rm /tmp/packages-microsoft-prod.deb - -sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg -sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg -echo -e "deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main -deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/wsl-transdebian.list > /dev/null - -sudo apt-get update -sudo apt-get install systemd-genie - -curl https://get.docker.com | sh - -sudo usermod -aG docker $USER - -sudo curl -L "https://github.com/docker/compose/releases/download/2.32.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose -sudo chmod +x /usr/local/bin/docker-compose - -echo "genie -i" >> ~/.bashrc - -exit \ No newline at end of file diff --git a/setup.sh b/setup.sh index 06e7846..cbd7130 100644 --- a/setup.sh +++ b/setup.sh @@ -1,159 +1,95 @@ #!/bin/bash -function ask_user() { - read -p "$1 (y/n): " choice - case "$choice" in - y|Y ) return 0;; - * ) return 1;; - esac -} +set -e +set -o pipefail -sed -i "s|^TZ=.*$|TZ=$(cat /etc/timezone)|" src/.env +# Ensure Docker is running +if ! command -v docker &> /dev/null; then + echo "❌ Docker not installed or not in PATH. Run system-prep.sh first." + exit 1 +fi -sudo apt update +# Set timezone in .env +if [ -f "src/.env" ]; then + timezone=$(cat /etc/timezone) + sed -i "s|^TZ=.*$|TZ=$timezone|" src/.env +else + echo "src/.env not found. Aborting." + exit 1 +fi -if ! command -v mysql &> /dev/null -then - echo "MySQL client is not installed. Installing mariadb-client now..." +if ! command -v mysql &> /dev/null; then + echo "[*] MySQL client not found. Installing mariadb-client..." + sudo apt-get update sudo apt install -y mariadb-client else - echo "MySQL client is already installed." -fi - -if ! command -v docker &> /dev/null -then - echo "Docker is not installed. Installing Docker now..." - sudo apt-get install ca-certificates curl - sudo install -m 0755 -d /etc/apt/keyrings - sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc - sudo chmod a+r /etc/apt/keyrings/docker.asc - - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - sudo apt-get update - sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - sudo usermod -aG docker $USER - echo "::NOTE::" - echo "Added your user to docker group to manage docker without root." - echo "Log out and back in and rerun setup.sh." - exit 1; -else - echo "Docker is already installed." + echo "✔️ MySQL client is already installed." fi +# Clone AzerothCore if not already if [ -d "azerothcore-wotlk" ]; then + echo "✔️ azerothcore-wotlk already exists. Cleaning SQL..." destination_dir="data/sql/custom" - - world=$destination_dir"/db_world/" - chars=$destination_dir"/db_characters/" - auth=$destination_dir"/db_auth/" - - cd azerothcore-wotlk - - rm -rf $world/*.sql - rm -rf $chars/*.sql - rm -rf $auth/*.sql - - cd .. - - cp src/.env azerothcore-wotlk/ - cp src/*.yml azerothcore-wotlk/ - cd azerothcore-wotlk + rm -rf "$destination_dir/db_world/"*.sql + rm -rf "$destination_dir/db_characters/"*.sql + rm -rf "$destination_dir/db_auth/"*.sql else - if ask_user "Download and install AzerothCore Playerbots?"; then - git clone https://github.com/liyunfan1223/azerothcore-wotlk.git --branch=Playerbot - cp src/.env azerothcore-wotlk/ - cp src/*.yml azerothcore-wotlk/ - cd azerothcore-wotlk/modules - git clone https://github.com/liyunfan1223/mod-playerbots.git --branch=master - cd .. - else - echo "Aborting..." - exit 1 - fi + echo "[*] Cloning AzerothCore..." + git clone https://github.com/liyunfan1223/azerothcore-wotlk.git --branch=Playerbot + echo "[*] Copying environment files..." + cp src/.env azerothcore-wotlk/ + cp src/*.yml azerothcore-wotlk/ + + # Install modules + cd azerothcore-wotlk/modules + git clone https://github.com/liyunfan1223/mod-playerbots.git --branch=master + git clone https://github.com/noisiver/mod-learnspells.git + git clone https://github.com/azerothcore/mod-autobalance.git + git clone https://github.com/azerothcore/mod-solo-lfg.git + git clone https://github.com/azerothcore/mod-individual-xp.git + cd .. fi -if ask_user "Install modules?"; then - - cd modules - - function install_mod() { - local mod_name=$1 - local repo_url=$2 - - if [ -d "${mod_name}" ]; then - echo "${mod_name} exists. Skipping..." - else - if ask_user "Install ${mod_name}?"; then - git clone "${repo_url}" - fi - fi - } - - install_mod "mod-aoe-loot" "https://github.com/azerothcore/mod-aoe-loot.git" - install_mod "mod-learn-spells" "https://github.com/noisiver/mod-learnspells.git" - install_mod "mod-fireworks-on-level" "https://github.com/azerothcore/mod-fireworks-on-level.git" - install_mod "mod-individual-progression" "https://github.com/notepadguyOfficial/mod-individual-progression" - install_mod "mod-junk-to-gold" "https://github.com/notepadguyOfficial/mod-junk-to-gold.git" - install_mod "mod-DungeonRespawn" "https://github.com/notepadguyOfficial/DungeonRespawn.git" - cd .. - -fi - - +# Build and start containers docker compose up -d --build - cd .. +# Fix ownership (if needed) sudo chown -R 1000:1000 wotlk +# Execute SQL custom_sql_dir="src/sql" auth="acore_auth" world="acore_world" chars="acore_characters" - ip_address=$(hostname -I | awk '{print $1}') -temp_sql_file="/tmp/temp_custom_sql.sql" - function execute_sql() { local db_name=$1 - local sql_files=("$custom_sql_dir/$db_name"/*.sql) + local dir="$custom_sql_dir/$db_name" - if [ -e "${sql_files[0]}" ]; then - for custom_sql_file in "${sql_files[@]}"; do - echo "Executing $custom_sql_file" + if [ -d "$dir" ] && compgen -G "$dir/*.sql" > /dev/null; then + for sql_file in "$dir"/*.sql; do + echo "Executing $sql_file" temp_sql_file=$(mktemp) - if [[ "$(basename "$custom_sql_file")" == "update_realmlist.sql" ]]; then - sed -e "s/{{IP_ADDRESS}}/$ip_address/g" "$custom_sql_file" > "$temp_sql_file" + if [[ "$(basename "$sql_file")" == "update_realmlist.sql" ]]; then + sed "s/{{IP_ADDRESS}}/$ip_address/g" "$sql_file" > "$temp_sql_file" else - cp "$custom_sql_file" "$temp_sql_file" + cp "$sql_file" "$temp_sql_file" fi mysql -h "$ip_address" -uroot -proot "$db_name" < "$temp_sql_file" + rm "$temp_sql_file" done else - echo "No SQL files found in $custom_sql_dir/$db_name, skipping..." + echo "No SQL files found in $dir, skipping..." fi } -echo "Running custom SQL files..." +echo "[*] Running SQL imports..." execute_sql "$auth" execute_sql "$world" execute_sql "$chars" -rm "$temp_sql_file" - echo "" -echo "NOTE:" -echo "" -echo "!!! If ac-db-import failed, run 'sudo chown -R 1000:1000 wotlk' and './setup.sh' again !!!" -echo "" -echo "1. Execute 'docker attach ac-worldserver'" -echo "2. 'account create username password' creates an account." -echo "3. 'account set gmlevel username 3 -1' sets the account as gm for all servers." -echo "4. Ctrl+p Ctrl+q will take you out of the world console." -echo "5. Edit your gameclients realmlist.wtf and set it to $ip_address." -echo "6. Now login to wow with 3.3.5a client!" -echo "7. All config files are copied into the wotlk folder created with setup.sh." +echo "✅ AzerothCore project setup complete!" +echo "👉 `docker attach ac-worldserver` Use the worldserver console to create accounts and set GM level as needed."