7.5 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			7.5 KiB
		
	
	
	
	
	
	
	
AppName.sh Scripts
AppName.sh scripts found in the /ct directory. These scripts are responsible for the installation of the desired application. For this guide we take /ct/snipeit.sh as example.
Table of Contents
- AppName.sh Scripts
1. File Header
1.1 Shebang
- Use #!/usr/bin/env bashas the shebang.
#!/usr/bin/env bash
1.2 Import Functions
- Import the build.func file.
- When developing your own script, change the URL to your own repository.
Important
You also need to change all apperances of this URL in
misc/build.funcandmisc/install.func
Example for development:
source <(curl -s https://raw.githubusercontent.com/[USER]/[REPO]/refs/heads/[BRANCH]/misc/build.func)
Final script:
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
Caution
Before opening a Pull Request, change the URLs to point to the community-scripts repo.
1.3 Metadata
- Add clear comments for script metadata, including author, copyright, and license information.
Example:
# Copyright (c) 2021-2025 community-scripts ORG
# Author: [YourUserName]
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: [SOURCE_URL]
[!NOTE]:
- Add your username and source URL
- For existing scripts, add "| Co-Author [YourUserName]" after the current author
2 Variables and function import
Note
You need to have all this set in your script, otherwise it will not work!
2.1 Default Values
- This section sets the default values for the container.
- APPneeds to be set to the application name and must be equal to the filenames of your scripts.
- var_tags: You can set Tags for the CT wich show up in the Proxmox UI. Don´t overdo it!
Note
Description for all Default Values
Variable Description Notes APPApplication name Must match ct\AppName.sh var_tagsProxmox display tags without Spaces, only ; Limit the number var_cpuCPU cores Number of cores var_ramRAM In MB var_diskDisk capacity In GB var_osOperating system alpine, debian, ubuntu var_versionOS version e.g., 3.20, 11, 12, 20.04 var_unprivilegedContainer type 1 = Unprivileged, 0 = Privileged 
Example:
APP="SnipeIT"
var_tags="asset-management;foss"
var_cpu="2"
var_ram="2048"
var_disk="4"
var_os="debian"
var_version="12"
var_unprivileged="1"
2.2 📋 App output & base settings
header_info "$APP"
- header_info: Generates ASCII header for APP
2.3 🛠 Core functions
variables
color
catch_errors
- variables: Processes input and prepares variables
- color: Sets icons, colors, and formatting
- catch_errors: Enables error handling
3 Update function
3.1 Function Header
- If applicable write a function that updates the application and the OS in the container.
- Each update function starts with the same code:
function update_script() {
  header_info
  check_container_storage
  check_container_resources
3.2 Check APP
- Before doing anything update-wise, check if the app is installed in the container.
Example:
if [[ ! -d /opt/snipe-it ]]; then
    msg_error "No ${APP} Installation Found!"
    exit
  fi
3.3 Check version
- Before updating, check if a new version exists.
- We use the ${APPLICATION}_version.txtfile created in/optduring the install to compare new versions against the currently installed version.
 
- We use the 
Example with a Github Release:
 RELEASE=$(curl -fsSL https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
  if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
    msg_info "Updating ${APP} to v${RELEASE}"
    #DO UPDATE
  else
    msg_ok "No update required. ${APP} is already at v${RELEASE}."
  fi
  exit
}
3.4 Verbosity
- Use the appropriate flag (-q in the examples) for a command to suppress its output. Example:
curl -fsSL
unzip -q
- If a command does not come with this functionality use $STDto suppress it's output.
Example:
$STD php artisan migrate --force
$STD php artisan config:clear
3.5 Backups
- Backup user data if necessary.
- Move all user data back in the directory when the update is finished.
Note
This is not meant to be a permanent backup
Example backup:
  mv /opt/snipe-it /opt/snipe-it-backup
Example config restore:
  cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
  cp -r /opt/snipe-it-backup/public/uploads/ /opt/snipe-it/public/uploads/
  cp -r /opt/snipe-it-backup/storage/private_uploads /opt/snipe-it/storage/private_uploads
3.6 Cleanup
- Do not forget to remove any temporary files/folders such as zip-files or temporary backups. Example:
  rm -rf /opt/v${RELEASE}.zip
  rm -rf /opt/snipe-it-backup
3.7 No update function
- In case you can not provide an update function use the following code to provide user feedback.
function update_script() {
    header_info
    check_container_storage
    check_container_resources
    if [[ ! -d /opt/snipeit ]]; then
        msg_error "No ${APP} Installation Found!"
        exit
    fi
    msg_error "Currently we don't provide an update function for this ${APP}."
    exit
}
4 End of the script
- start: Launches Whiptail dialogue
- build_container: Collects and integrates user settings
- description: Sets LXC container description
- With echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"you can point the user to the IP:PORT/folder needed to access the app.
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}${CL}"
5. Contribution checklist
- Shebang is correctly set (#!/usr/bin/env bash).
- Correct link to build.func
- Metadata (author, license) is included at the top.
- Variables follow naming conventions.
- Update function exists.
- Update functions checks if app is installed and for new version.
- Update function cleans up temporary files.
- Script ends with a helpful message for the user to reach the application.
