43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
# Installer for Linux System Updater (.tar.gz distribution)
|
|
PREFIX="${PREFIX:-/usr/local}"
|
|
SYSCONFDIR="${SYSCONFDIR:-/etc}"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "Error: Installation requires root/sudo privileges." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing Linux System Updater to ${PREFIX}..."
|
|
|
|
# Create target directories
|
|
mkdir -p "${PREFIX}/bin"
|
|
mkdir -p "${PREFIX}/lib/linux-updater"
|
|
mkdir -p "${SYSCONFDIR}"
|
|
mkdir -p /var/log/linux-updater
|
|
chmod 750 /var/log/linux-updater || chmod 755 /var/log/linux-updater
|
|
|
|
# Copy package modules
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cp -r "${SCRIPT_DIR}/linux_updater" "${PREFIX}/lib/linux-updater/"
|
|
|
|
# Install launcher
|
|
install -m 755 "${SCRIPT_DIR}/bin/linux-updater" "${PREFIX}/bin/linux-updater"
|
|
|
|
# Install default config if not existing
|
|
if [ ! -f "${SYSCONFDIR}/linux-updater.json" ] && [ -f "${SCRIPT_DIR}/linux-updater.json.example" ]; then
|
|
echo "Installing default configuration to ${SYSCONFDIR}/linux-updater.json..."
|
|
cp "${SCRIPT_DIR}/linux-updater.json.example" "${SYSCONFDIR}/linux-updater.json"
|
|
chmod 644 "${SYSCONFDIR}/linux-updater.json"
|
|
fi
|
|
|
|
# Install man page
|
|
if [ -f "${SCRIPT_DIR}/man/linux-updater.8" ]; then
|
|
mkdir -p "${PREFIX}/share/man/man8"
|
|
install -m 644 "${SCRIPT_DIR}/man/linux-updater.8" "${PREFIX}/share/man/man8/linux-updater.8"
|
|
fi
|
|
|
|
echo "Installation complete! Run 'linux-updater --help' to verify."
|