#!/bin/sh # postinst script for apt-ostree # # This script is executed after the package is unpacked and configured. # It handles post-installation tasks such as creating directories, # setting up configuration files, and updating system caches. set -e # Source debconf library . /usr/share/debconf/confmodule # Package name PACKAGE="apt-ostree" # Configuration directories CONFIG_DIR="/etc/apt-ostree" DATA_DIR="/var/lib/apt-ostree" LOG_DIR="/var/log/apt-ostree" # OSTree system directory OSTREE_DIR="/ostree" case "$1" in configure) echo "Configuring $PACKAGE..." # Create necessary directories mkdir -p "$CONFIG_DIR" mkdir -p "$DATA_DIR" mkdir -p "$LOG_DIR" # Set proper permissions chmod 755 "$CONFIG_DIR" chmod 755 "$DATA_DIR" chmod 755 "$LOG_DIR" # Create default configuration file if it doesn't exist if [ ! -f "$CONFIG_DIR/config.toml" ]; then cat > "$CONFIG_DIR/config.toml" << 'EOF' # apt-ostree configuration file # Generated automatically during package installation [general] # Log level: trace, debug, info, warn, error log_level = "info" # Data directory for apt-ostree data_dir = "/var/lib/apt-ostree" # OSTree system directory ostree_dir = "/ostree" [apt] # APT configuration overrides # These settings will be used instead of system defaults if specified [ostree] # OSTree configuration overrides # These settings will be used instead of system defaults if specified [security] # Security settings # Enable package signature verification verify_signatures = true # Enable sandboxing for package operations enable_sandbox = true EOF chmod 644 "$CONFIG_DIR/config.toml" echo "Created default configuration file: $CONFIG_DIR/config.toml" fi # Create log rotation configuration if [ ! -f "/etc/logrotate.d/apt-ostree" ]; then cat > "/etc/logrotate.d/apt-ostree" << 'EOF' /var/log/apt-ostree/*.log { daily missingok rotate 7 compress delaycompress notifempty create 644 root root postrotate # Reload any services if needed systemctl reload apt-ostree > /dev/null 2>&1 || true endscript } EOF chmod 644 "/etc/logrotate.d/apt-ostree" echo "Created log rotation configuration" fi # Check if OSTree is available and configured if command -v ostree >/dev/null 2>&1; then echo "OSTree is available on the system" # Check if OSTree repository exists if [ -d "$OSTREE_DIR" ]; then echo "OSTree repository directory exists: $OSTREE_DIR" else echo "Note: OSTree repository directory does not exist: $OSTREE_DIR" echo "You may need to initialize OSTree before using apt-ostree" fi else echo "Warning: OSTree is not available on the system" echo "apt-ostree requires OSTree to function properly" echo "Please install the 'ostree' package" fi # Update shell completion caches if command -v update-bash-completion >/dev/null 2>&1; then update-bash-completion apt-ostree || true fi # Update man page database if command -v mandb >/dev/null 2>&1; then mandb -q || true fi echo "$PACKAGE configuration completed successfully" ;; abort-upgrade|abort-remove|abort-deconfigure) # Handle upgrade/removal failures echo "Aborting $PACKAGE configuration..." ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # Exit successfully exit 0