mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Add Habitica script (#2779)
This commit is contained in:
		
							
								
								
									
										74
									
								
								ct/habitica.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								ct/habitica.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,74 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/HabitRPG/habitica
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					APP="Habitica"
 | 
				
			||||||
 | 
					var_tags="gaming"
 | 
				
			||||||
 | 
					var_cpu="2"
 | 
				
			||||||
 | 
					var_ram="4096"
 | 
				
			||||||
 | 
					var_disk="8"
 | 
				
			||||||
 | 
					var_os="debian"
 | 
				
			||||||
 | 
					var_version="12"
 | 
				
			||||||
 | 
					var_unprivileged="1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header_info "$APP"
 | 
				
			||||||
 | 
					variables
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function update_script() {
 | 
				
			||||||
 | 
					    header_info
 | 
				
			||||||
 | 
					    check_container_storage
 | 
				
			||||||
 | 
					    check_container_resources
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ ! -d "/opt/habitica" ]]; then
 | 
				
			||||||
 | 
					        msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
 | 
					        exit
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    RELEASE=$(curl -s https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					    if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
 | 
				
			||||||
 | 
					        msg_info "Stopping $APP"
 | 
				
			||||||
 | 
					        systemctl stop habitica-mongodb
 | 
				
			||||||
 | 
					        systemctl stop habitica
 | 
				
			||||||
 | 
					        systemctl stop habitica-client
 | 
				
			||||||
 | 
					        msg_ok "Stopped $APP"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        msg_info "Updating $APP to ${RELEASE}"
 | 
				
			||||||
 | 
					        temp_file=$(mktemp)
 | 
				
			||||||
 | 
					        wget -q "https://github.com/HabitRPG/habitica/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
 | 
				
			||||||
 | 
					        tar zxf $temp_file
 | 
				
			||||||
 | 
					        cp -rf habitica-${RELEASE}/* /opt/habitica
 | 
				
			||||||
 | 
					        cd /opt/habitica
 | 
				
			||||||
 | 
					        $STD npm i
 | 
				
			||||||
 | 
					        echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
				
			||||||
 | 
					        msg_ok "Updated $APP to ${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        msg_info "Starting $APP"
 | 
				
			||||||
 | 
					        systemctl start habitica-mongodb
 | 
				
			||||||
 | 
					        systemctl start habitica
 | 
				
			||||||
 | 
					        systemctl start habitica-client
 | 
				
			||||||
 | 
					        msg_ok "Started $APP"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        msg_info "Cleaning Up"
 | 
				
			||||||
 | 
					        rm -f $temp_file
 | 
				
			||||||
 | 
					        rm -rf ~/habitica-${RELEASE}
 | 
				
			||||||
 | 
					        msg_ok "Cleanup Completed"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        msg_ok "Update Successful"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    exit
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					start
 | 
				
			||||||
 | 
					build_container
 | 
				
			||||||
 | 
					description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_ok "Completed Successfully!\n"
 | 
				
			||||||
 | 
					echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
				
			||||||
 | 
					echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
				
			||||||
 | 
					echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"
 | 
				
			||||||
							
								
								
									
										110
									
								
								install/habitica-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								install/habitica-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/HabitRPG/habitica
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					verb_ip6
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					setting_up_container
 | 
				
			||||||
 | 
					network_check
 | 
				
			||||||
 | 
					update_os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing Dependencies"
 | 
				
			||||||
 | 
					$STD apt-get install -y \
 | 
				
			||||||
 | 
					    curl \
 | 
				
			||||||
 | 
					    sudo \
 | 
				
			||||||
 | 
					    mc \
 | 
				
			||||||
 | 
					    libkrb5-dev \
 | 
				
			||||||
 | 
					    gnupg \
 | 
				
			||||||
 | 
					    build-essential \
 | 
				
			||||||
 | 
					    git
 | 
				
			||||||
 | 
					wget -q http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
 | 
				
			||||||
 | 
					$STD dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
 | 
				
			||||||
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Setting up Node.js Repository"
 | 
				
			||||||
 | 
					mkdir -p /etc/apt/keyrings
 | 
				
			||||||
 | 
					curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
 | 
				
			||||||
 | 
					echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
 | 
				
			||||||
 | 
					msg_ok "Set up Node.js Repository"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Setup Node.js"
 | 
				
			||||||
 | 
					$STD apt-get update
 | 
				
			||||||
 | 
					$STD apt-get install -y nodejs
 | 
				
			||||||
 | 
					msg_ok "Setup Node.js"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Setup ${APPLICATION}"
 | 
				
			||||||
 | 
					temp_file=$(mktemp)
 | 
				
			||||||
 | 
					RELEASE=$(curl -s https://api.github.com/repos/HabitRPG/habitica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					wget -q "https://github.com/HabitRPG/habitica/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
 | 
				
			||||||
 | 
					tar zxf $temp_file
 | 
				
			||||||
 | 
					mv habitica-${RELEASE}/ /opt/habitica
 | 
				
			||||||
 | 
					cd /opt/habitica
 | 
				
			||||||
 | 
					$STD npm i
 | 
				
			||||||
 | 
					cp config.json.example config.json
 | 
				
			||||||
 | 
					echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
 | 
				
			||||||
 | 
					msg_ok "Setup ${APPLICATION}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Creating Service"
 | 
				
			||||||
 | 
					cat <<EOF >/etc/systemd/system/habitica-mongodb.service
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=Habitica MongoDB Service
 | 
				
			||||||
 | 
					After=network.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					User=root
 | 
				
			||||||
 | 
					WorkingDirectory=/opt/habitica
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/npm run mongo:dev
 | 
				
			||||||
 | 
					Restart=always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					cat <<EOF >/etc/systemd/system/habitica.service
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=Habitica Service
 | 
				
			||||||
 | 
					After=habitica-mongodb.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					User=root
 | 
				
			||||||
 | 
					WorkingDirectory=/opt/habitica
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/npm start
 | 
				
			||||||
 | 
					Restart=always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					cat <<EOF >/etc/systemd/system/habitica-client.service
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=Habitica Client Service
 | 
				
			||||||
 | 
					After=habitica.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					User=root
 | 
				
			||||||
 | 
					WorkingDirectory=/opt/habitica
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/npm run client:dev
 | 
				
			||||||
 | 
					Restart=always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					systemctl enable -q --now habitica-mongodb
 | 
				
			||||||
 | 
					systemctl enable -q --now habitica
 | 
				
			||||||
 | 
					systemctl enable -q --now habitica-client
 | 
				
			||||||
 | 
					msg_ok "Created Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					motd_ssh
 | 
				
			||||||
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
 | 
					rm -f $temp_file
 | 
				
			||||||
 | 
					$STD apt-get -y autoremove
 | 
				
			||||||
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
							
								
								
									
										43
									
								
								json/habitica.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								json/habitica.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "name": "Habitica",
 | 
				
			||||||
 | 
					    "slug": "habitica",
 | 
				
			||||||
 | 
					    "categories": [
 | 
				
			||||||
 | 
					        24
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "date_created": "2025-03-02",
 | 
				
			||||||
 | 
					    "type": "ct",
 | 
				
			||||||
 | 
					    "updateable": true,
 | 
				
			||||||
 | 
					    "privileged": false,
 | 
				
			||||||
 | 
					    "interface_port": 8080,
 | 
				
			||||||
 | 
					    "documentation": "https://github.com/HabitRPG/habitica/wiki",
 | 
				
			||||||
 | 
					    "website": "https://habitica.com/",
 | 
				
			||||||
 | 
					    "logo": "https://github.com/HabitRPG/habitica/raw/refs/heads/develop/website/client/src/assets/svg/logo.svg",
 | 
				
			||||||
 | 
					    "description": "Habitica is an open-source habit-building program that treats your life like a role-playing game. Level up as you succeed, lose HP as you fail, and earn Gold to buy weapons and armor!",
 | 
				
			||||||
 | 
					    "install_methods": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "type": "default",
 | 
				
			||||||
 | 
					            "script": "ct/habitica.sh",
 | 
				
			||||||
 | 
					            "resources": {
 | 
				
			||||||
 | 
					                "cpu": 2,
 | 
				
			||||||
 | 
					                "ram": 4096,
 | 
				
			||||||
 | 
					                "hdd": 8,
 | 
				
			||||||
 | 
					                "os": "debian",
 | 
				
			||||||
 | 
					                "version": "12"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "default_credentials": {
 | 
				
			||||||
 | 
					        "username": null,
 | 
				
			||||||
 | 
					        "password": null
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "notes": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "text": "It takes a minute or two after installation for web UI to start, please be patient.",
 | 
				
			||||||
 | 
					            "type": "info"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "text": "Config file is at `/opt/habitica/config.json`",
 | 
				
			||||||
 | 
					            "type": "info"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user