mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Add new LXC: Kimai (#397)
* Add new LXC: Kimai * little tweak, admin instead of username * Update ct/kimai.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update json/kimai.json Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update install/kimai-install.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update install/kimai-install.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update install/kimai-install.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update ct/kimai.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update install/kimai-install.sh Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Add RELEASE Output Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Remove Sudo from mysql Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Remove Sudo from mysql Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Remove Sudo from mysql Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update json/kimai.json Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> * Update json/kimai.json Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> --------- Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										104
									
								
								ct/kimai.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								ct/kimai.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2024 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: MickLesk (Canbiz)
 | 
				
			||||||
 | 
					# License: MIT
 | 
				
			||||||
 | 
					# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function header_info {
 | 
				
			||||||
 | 
					clear
 | 
				
			||||||
 | 
					cat <<"EOF"
 | 
				
			||||||
 | 
					    __ __ _                 _ 
 | 
				
			||||||
 | 
					   / //_/(_)___ ___  ____ _(_)
 | 
				
			||||||
 | 
					  / ,<  / / __ `__ \/ __ `/ / 
 | 
				
			||||||
 | 
					 / /| |/ / / / / / / /_/ / /  
 | 
				
			||||||
 | 
					/_/ |_/_/_/ /_/ /_/\__,_/_/   
 | 
				
			||||||
 | 
					                              
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					header_info
 | 
				
			||||||
 | 
					echo -e "Loading..."
 | 
				
			||||||
 | 
					APP="Kimai"
 | 
				
			||||||
 | 
					var_disk="7"
 | 
				
			||||||
 | 
					var_cpu="2"
 | 
				
			||||||
 | 
					var_ram="2048"
 | 
				
			||||||
 | 
					var_os="debian"
 | 
				
			||||||
 | 
					var_version="12"
 | 
				
			||||||
 | 
					variables
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function default_settings() {
 | 
				
			||||||
 | 
					  CT_TYPE="1"
 | 
				
			||||||
 | 
					  PW=""
 | 
				
			||||||
 | 
					  CT_ID=$NEXTID
 | 
				
			||||||
 | 
					  HN=$NSAPP
 | 
				
			||||||
 | 
					  DISK_SIZE="$var_disk"
 | 
				
			||||||
 | 
					  CORE_COUNT="$var_cpu"
 | 
				
			||||||
 | 
					  RAM_SIZE="$var_ram"
 | 
				
			||||||
 | 
					  BRG="vmbr0"
 | 
				
			||||||
 | 
					  NET="dhcp"
 | 
				
			||||||
 | 
					  GATE=""
 | 
				
			||||||
 | 
					  APT_CACHER=""
 | 
				
			||||||
 | 
					  APT_CACHER_IP=""
 | 
				
			||||||
 | 
					  DISABLEIP6="no"
 | 
				
			||||||
 | 
					  MTU=""
 | 
				
			||||||
 | 
					  SD=""
 | 
				
			||||||
 | 
					  NS=""
 | 
				
			||||||
 | 
					  MAC=""
 | 
				
			||||||
 | 
					  VLAN=""
 | 
				
			||||||
 | 
					  SSH="no"
 | 
				
			||||||
 | 
					  VERB="no"
 | 
				
			||||||
 | 
					  echo_default
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function update_script() {
 | 
				
			||||||
 | 
					header_info
 | 
				
			||||||
 | 
					check_container_storage
 | 
				
			||||||
 | 
					check_container_resources
 | 
				
			||||||
 | 
					if [[ ! -d /opt/kimai ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
 | 
				
			||||||
 | 
					RELEASE=$(curl -s https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
 | 
				
			||||||
 | 
					if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
 | 
				
			||||||
 | 
					  msg_info "Stopping Apache2"
 | 
				
			||||||
 | 
					  systemctl stop apache2
 | 
				
			||||||
 | 
					  msg_ok "Stopped Apache2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  msg_info "Updating ${APP} to ${RELEASE}"
 | 
				
			||||||
 | 
					  cp /opt/kimai/.env /opt/.env
 | 
				
			||||||
 | 
					  rm -rf /opt/kimai
 | 
				
			||||||
 | 
					  wget -q "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip"
 | 
				
			||||||
 | 
					  unzip -q ${RELEASE}.zip
 | 
				
			||||||
 | 
					  mv kimai-${RELEASE} /opt/kimai
 | 
				
			||||||
 | 
					  mv /opt/.env /opt/kimai/.env
 | 
				
			||||||
 | 
					  cd /opt/kimai
 | 
				
			||||||
 | 
					  composer install --no-dev --optimize-autoloader &>/dev/null
 | 
				
			||||||
 | 
					  bin/console kimai:update &>/dev/null
 | 
				
			||||||
 | 
					  chown -R :www-data .
 | 
				
			||||||
 | 
					  chmod -R g+r .
 | 
				
			||||||
 | 
					  chmod -R g+rw var/
 | 
				
			||||||
 | 
					  sudo chown -R www-data:www-data /opt/kimai
 | 
				
			||||||
 | 
					  sudo chmod -R 755 /opt/kimai
 | 
				
			||||||
 | 
					  echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
				
			||||||
 | 
					  msg_ok "Updated ${APP} to ${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  msg_info "Starting Apache2"
 | 
				
			||||||
 | 
					  systemctl start apache2
 | 
				
			||||||
 | 
					  msg_ok "Started Apache2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  msg_info "Cleaning Up"
 | 
				
			||||||
 | 
					  rm -rf ${RELEASE}.zip
 | 
				
			||||||
 | 
					  msg_ok "Cleaned"
 | 
				
			||||||
 | 
					  msg_ok "Updated Successfully"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					exit
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					start
 | 
				
			||||||
 | 
					build_container
 | 
				
			||||||
 | 
					description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_ok "Completed Successfully!\n"
 | 
				
			||||||
 | 
					echo -e "${APP} Setup should be reachable by going to the following URL.
 | 
				
			||||||
 | 
					         ${BL}http://${IP}${CL} \n"
 | 
				
			||||||
							
								
								
									
										107
									
								
								install/kimai-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								install/kimai-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,107 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2024 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: MickLesk
 | 
				
			||||||
 | 
					# License: MIT
 | 
				
			||||||
 | 
					# https://github.com/tteck/Proxmox/raw/main/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 \
 | 
				
			||||||
 | 
					  apt-transport-https \
 | 
				
			||||||
 | 
					  sudo \
 | 
				
			||||||
 | 
					  mc \
 | 
				
			||||||
 | 
					  curl \
 | 
				
			||||||
 | 
					  apache2 \
 | 
				
			||||||
 | 
					  git \
 | 
				
			||||||
 | 
					  expect \
 | 
				
			||||||
 | 
					  composer \
 | 
				
			||||||
 | 
					  mariadb-server \
 | 
				
			||||||
 | 
					  libapache2-mod-php \
 | 
				
			||||||
 | 
					  php8.2-{mbstring,gd,intl,pdo,mysql,tokenizer,zip,xml} 
 | 
				
			||||||
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Setting up database"
 | 
				
			||||||
 | 
					DB_NAME=kimai_db
 | 
				
			||||||
 | 
					DB_USER=kimai
 | 
				
			||||||
 | 
					DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
 | 
				
			||||||
 | 
					MYSQL_VERSION=$(mysql --version | grep -oP 'Distrib \K[0-9]+\.[0-9]+\.[0-9]+')
 | 
				
			||||||
 | 
					mysql -u root -e "CREATE DATABASE $DB_NAME;"
 | 
				
			||||||
 | 
					mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
 | 
				
			||||||
 | 
					mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    echo "Kimai-Credentials"
 | 
				
			||||||
 | 
					    echo "Kimai Database User: $DB_USER"
 | 
				
			||||||
 | 
					    echo "Kimai Database Password: $DB_PASS"
 | 
				
			||||||
 | 
					    echo "Kimai Database Name: $DB_NAME"
 | 
				
			||||||
 | 
					} >> ~/kimai.creds
 | 
				
			||||||
 | 
					msg_ok "Set up database"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing Kimai (Patience)"
 | 
				
			||||||
 | 
					RELEASE=$(curl -s https://api.github.com/repos/kimai/kimai/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
 | 
				
			||||||
 | 
					wget -q "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip"
 | 
				
			||||||
 | 
					unzip -q ${RELEASE}.zip
 | 
				
			||||||
 | 
					mv kimai-${RELEASE} /opt/kimai
 | 
				
			||||||
 | 
					cd /opt/kimai
 | 
				
			||||||
 | 
					echo "export COMPOSER_ALLOW_SUPERUSER=1" >> ~/.bashrc
 | 
				
			||||||
 | 
					source ~/.bashrc
 | 
				
			||||||
 | 
					$STD composer install --no-dev --optimize-autoloader --no-interaction
 | 
				
			||||||
 | 
					cp .env.dist .env
 | 
				
			||||||
 | 
					sed -i "/^DATABASE_URL=/c\DATABASE_URL=mysql://$DB_USER:$DB_PASS@127.0.0.1:3306/$DB_NAME?charset=utf8mb4&serverVersion=$MYSQL_VERSION" /opt/kimai/.env
 | 
				
			||||||
 | 
					$STD bin/console kimai:install -n
 | 
				
			||||||
 | 
					chown -R :www-data .
 | 
				
			||||||
 | 
					chmod -R g+r .
 | 
				
			||||||
 | 
					chmod -R g+rw var/
 | 
				
			||||||
 | 
					sudo chown -R www-data:www-data /opt/kimai
 | 
				
			||||||
 | 
					sudo chmod -R 755 /opt/kimai
 | 
				
			||||||
 | 
					$STD expect <<EOF
 | 
				
			||||||
 | 
					set timeout -1
 | 
				
			||||||
 | 
					log_user 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					spawn bin/console kimai:user:create admin admin@helper-scripts.com ROLE_SUPER_ADMIN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect "Please enter the password:"
 | 
				
			||||||
 | 
					send "helper-scripts.com\r"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect eof
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 | 
				
			||||||
 | 
					msg_ok "Installed Kimai"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Creating Service"
 | 
				
			||||||
 | 
					cat <<EOF >/etc/apache2/sites-available/kimai.conf
 | 
				
			||||||
 | 
					<VirtualHost *:80>
 | 
				
			||||||
 | 
					  ServerAdmin webmaster@localhost
 | 
				
			||||||
 | 
					  DocumentRoot /opt/kimai/public/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   <Directory /opt/kimai/public>
 | 
				
			||||||
 | 
					        Options FollowSymLinks
 | 
				
			||||||
 | 
					        AllowOverride All
 | 
				
			||||||
 | 
					        Require all granted
 | 
				
			||||||
 | 
					    </Directory>
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    ErrorLog /var/log/apache2/error.log
 | 
				
			||||||
 | 
					    CustomLog /var/log/apache2/access.log combined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</VirtualHost>
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					$STD a2ensite kimai.conf
 | 
				
			||||||
 | 
					$STD a2dissite 000-default.conf  
 | 
				
			||||||
 | 
					$STD systemctl reload apache2
 | 
				
			||||||
 | 
					msg_ok "Created Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					motd_ssh
 | 
				
			||||||
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
 | 
					rm -rf ${RELEASE}.zip
 | 
				
			||||||
 | 
					$STD apt-get -y autoremove
 | 
				
			||||||
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
							
								
								
									
										34
									
								
								json/kimai.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								json/kimai.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "Kimai",
 | 
				
			||||||
 | 
					  "slug": "kimai",
 | 
				
			||||||
 | 
					  "categories": [
 | 
				
			||||||
 | 
					    0
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "date_created": "2024-11-20",
 | 
				
			||||||
 | 
					  "type": "ct",
 | 
				
			||||||
 | 
					  "updateable": true,
 | 
				
			||||||
 | 
					  "privileged": false,
 | 
				
			||||||
 | 
					  "interface_port": null,
 | 
				
			||||||
 | 
					  "documentation": "https://www.kimai.org/documentation/",
 | 
				
			||||||
 | 
					  "website": "https://www.kimai.org/",
 | 
				
			||||||
 | 
					  "logo": "https://raw.githubusercontent.com/kimai/images/refs/heads/main/logo-transparent.png",
 | 
				
			||||||
 | 
					  "description": "Kimai is an open-source time-tracking software designed for freelancers, small teams, and businesses to efficiently track, manage, and analyze work hours. This web-based tool enables users to log their work time with ease, associating entries with specific clients, projects, and tasks.",
 | 
				
			||||||
 | 
					  "install_methods": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "type": "default",
 | 
				
			||||||
 | 
					      "script": "/ct/kimai.sh",
 | 
				
			||||||
 | 
					      "resources": {
 | 
				
			||||||
 | 
					        "cpu": "2",
 | 
				
			||||||
 | 
					        "ram": "2048",
 | 
				
			||||||
 | 
					        "hdd": "7",
 | 
				
			||||||
 | 
					        "os": "Debian",
 | 
				
			||||||
 | 
					        "version": 12
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "default_credentials": {
 | 
				
			||||||
 | 
					    "username": "admin@helper-scripts.com",
 | 
				
			||||||
 | 
					    "password": "helper-scripts.com"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "notes": []
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user