Add install_osticket.sh
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit immediately if a command exits with a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# --- INTERACTIVE PROMPT ---
|
||||||
|
read -p "Enter the target installation directory [/var/www/html/osticket]: " INSTALL_DIR
|
||||||
|
INSTALL_DIR="${INSTALL_DIR:-/var/www/html/osticket}"
|
||||||
|
|
||||||
|
# --- CONFIGURATION ---
|
||||||
|
# IMPORTANT: Adjust these for your OS.
|
||||||
|
# Fedora/RHEL/CentOS typically uses 'apache'
|
||||||
|
# Ubuntu/Debian typically uses 'www-data'
|
||||||
|
read -p "Enter web server user [apache]: " WEB_USER
|
||||||
|
WEB_USER="${WEB_USER:-apache}"
|
||||||
|
read -p "Enter web server group [apache]: " WEB_GROUP
|
||||||
|
WEB_GROUP="${WEB_GROUP:-apache}"
|
||||||
|
|
||||||
|
OSTICKET_VERSION="v1.18.3"
|
||||||
|
DOWNLOAD_URL="https://github.com/osTicket/osTicket/releases/download/${OSTICKET_VERSION}/osTicket-${OSTICKET_VERSION}.zip"
|
||||||
|
|
||||||
|
echo "=== Starting osTicket ${OSTICKET_VERSION} Installation ==="
|
||||||
|
echo "Target Directory: ${INSTALL_DIR}"
|
||||||
|
|
||||||
|
# 1. Set SELinux to Permissive mode
|
||||||
|
echo "Setting SELinux to permissive mode..."
|
||||||
|
sudo setenforce 0
|
||||||
|
|
||||||
|
# 2. Ensure required dependencies are present
|
||||||
|
if ! command -v unzip &> /dev/null || ! command -v wget &> /dev/null; then
|
||||||
|
echo "Installing required dependencies (unzip, wget)..."
|
||||||
|
if [ -f /etc/debian_version ]; then
|
||||||
|
sudo apt-get update && sudo apt-get install -y unzip wget
|
||||||
|
elif [ -f /etc/redhat-release ]; then
|
||||||
|
sudo dnf install -y unzip wget
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Create the target directory
|
||||||
|
echo "Creating target directory..."
|
||||||
|
sudo mkdir -p "${INSTALL_DIR}"
|
||||||
|
|
||||||
|
# 4. Download osTicket archive
|
||||||
|
echo "Downloading osTicket..."
|
||||||
|
TEMP_DIR=$(mktemp -d)
|
||||||
|
wget -q "${DOWNLOAD_URL}" -O "${TEMP_DIR}/osticket.zip"
|
||||||
|
|
||||||
|
# 5. Extract files to the target directory
|
||||||
|
echo "Extracting files..."
|
||||||
|
sudo unzip -q "${TEMP_DIR}/osticket.zip" -d "${TEMP_DIR}/extracted"
|
||||||
|
sudo cp -r "${TEMP_DIR}/extracted/upload/"* "${INSTALL_DIR}/"
|
||||||
|
|
||||||
|
# Clean up temp directory
|
||||||
|
rm -rf "${TEMP_DIR}"
|
||||||
|
|
||||||
|
# 6. Rename the configuration file
|
||||||
|
echo "Renaming ost-sampleconfig.php to ost-config.php..."
|
||||||
|
if [ -f "${INSTALL_DIR}/include/ost-sampleconfig.php" ]; then
|
||||||
|
sudo mv "${INSTALL_DIR}/include/ost-sampleconfig.php" "${INSTALL_DIR}/include/ost-config.php"
|
||||||
|
else
|
||||||
|
echo "Error: Sample configuration file not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 7. Apply permissions and set ownership
|
||||||
|
echo "Applying permissions and setting ownership for user: ${WEB_USER}..."
|
||||||
|
sudo chown -R "${WEB_USER}:${WEB_GROUP}" "${INSTALL_DIR}"
|
||||||
|
sudo chmod 0755 "${INSTALL_DIR}"
|
||||||
|
sudo chmod 0666 "${INSTALL_DIR}/include/ost-config.php"
|
||||||
|
|
||||||
|
echo "=== Installation Complete! ==="
|
||||||
|
echo "osTicket is ready at: ${INSTALL_DIR}"
|
||||||
|
echo "You can now complete the setup via your browser."
|
||||||
Reference in New Issue
Block a user