diff --git a/install.sh b/install.sh index 4b269a2..973632d 100644 --- a/install.sh +++ b/install.sh @@ -7,9 +7,15 @@ YELLOW='\033[0;33m' # Added yellow for warnings/info NC='\033[0m' # No Color - resets text to default color install_prereqs() { - echo -e "${GREEN}Installing Prerequisites...${NC}" - apt-get update - apt-get install docker.io + if id -Gn $(whoami) | grep -qw docker; then + echo -e "${GREEN}Prerequisites Already Installed${NC}" + else + echo -e "${GREEN}Installing Prerequisites...${NC}" + sudo apt-get update -y + sudo apt-get install docker.io -y + sudo usermod -aG docker $(whoami) + sudo reboot + fi } install_discord_bot() { @@ -23,15 +29,16 @@ install_discord_bot() { echo -e "${RED}Warning: Could not stop/remove existing container '${drb_container_name}'. It might not be running.${NC}" fi fi + mkdir -p $(pwd)/configs echo -e "${GREEN}Installing the discord bot...${NC}" docker pull git.vpn.cusano.net/logan/drb-client-discord-bot/drb-client-discord-bot:nightly - docker run -d --privileged + docker run -d --privileged \ -v /dev:/dev \ - -v $(shell pwd)/configs:/configs \ + -v $(pwd)/configs:/configs \ --name "${drb_container_name}" \ --network=host \ --restart unless-stopped \ - "${drb_container_name}" + git.vpn.cusano.net/logan/drb-client-discord-bot/drb-client-discord-bot:nightly } create_config_json() { @@ -45,8 +52,11 @@ create_config_json() { "nickname": "" }' + # Create data folder if it doesn't exist + mkdir -p ./data + # Write the content to config.json - echo "$config_content" > config.json + echo "$config_content" > ./data/config.json # Check if the file was successfully created if [ -f "config.json" ]; then @@ -88,7 +98,7 @@ start_docker_container() { if docker run -d \ --name "${container_name}" \ --restart unless-stopped \ - -v "$PWD/data":/data \ + -v "$(pwd)/data":/data \ --network=host \ "${image_name}"; then echo -e "${GREEN}Docker container '${container_name}' started successfully in detached mode.${NC}" @@ -103,16 +113,16 @@ start_docker_container() { # --- Main script execution --- -# 1. Install PreReqs +# Install PreReqs install_prereqs -# 2. Check Docker status -check_docker_status - -# 3. Create config.json +# Create config.json create_config_json -# 4. Build and Start Docker container +# Build and Start Docker container start_docker_container +# Download the drb discord bot +install_discord_bot + echo -e "${GREEN}--- All installation and startup steps finished ---${NC}" \ No newline at end of file