#!/bin/sh # APPNAMEctl - Management CLI for APPNAME # Auto-generated by RezApp Forge from SOURCE_IMAGE CONTAINER="APPNAME" CONFIG="APPNAME" usage() { cat < Commands: start Start the APPNAME container stop Stop the APPNAME container restart Restart the APPNAME container status Show container status logs Show container logs shell Open shell in container enable Enable auto-start disable Disable auto-start help Show this help EOF } cmd_start() { /etc/init.d/$CONFIG start } cmd_stop() { /etc/init.d/$CONFIG stop } cmd_restart() { /etc/init.d/$CONFIG restart } cmd_status() { echo "=== APPNAME Status ===" if lxc-info -n "$CONTAINER" 2>/dev/null | grep -q "RUNNING"; then lxc-info -n "$CONTAINER" else echo "Container is not running" echo "" echo "Config: /etc/config/$CONFIG" uci show $CONFIG 2>/dev/null || echo "(no config)" fi } cmd_logs() { if lxc-info -n "$CONTAINER" 2>/dev/null | grep -q "RUNNING"; then # Try common log locations for log in /var/log/APPNAME.log /var/log/messages /tmp/APPNAME.log; do if lxc-attach -n "$CONTAINER" -- test -f "$log" 2>/dev/null; then lxc-attach -n "$CONTAINER" -- tail -100 "$log" return fi done echo "No log files found in container" else echo "Container is not running" fi } cmd_shell() { if lxc-info -n "$CONTAINER" 2>/dev/null | grep -q "RUNNING"; then lxc-attach -n "$CONTAINER" -- /bin/sh else echo "Container is not running. Start it first with: APPNAMEctl start" fi } cmd_enable() { uci set $CONFIG.main.enabled='1' uci commit $CONFIG /etc/init.d/$CONFIG enable echo "APPNAME enabled for auto-start" } cmd_disable() { uci set $CONFIG.main.enabled='0' uci commit $CONFIG /etc/init.d/$CONFIG disable echo "APPNAME disabled" } case "$1" in start) cmd_start ;; stop) cmd_stop ;; restart) cmd_restart ;; status) cmd_status ;; logs) cmd_logs ;; shell) cmd_shell ;; enable) cmd_enable ;; disable) cmd_disable ;; help|--help|-h|"") usage ;; *) echo "Unknown command: $1" usage exit 1 ;; esac