50 lines
No EOL
1.3 KiB
Bash
Executable file
50 lines
No EOL
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Script to install wkhtmltopdf on the server
|
|
|
|
echo "Checking for wkhtmltopdf..."
|
|
if command -v wkhtmltopdf &> /dev/null; then
|
|
echo "wkhtmltopdf is already installed at $(which wkhtmltopdf)"
|
|
wkhtmltopdf --version
|
|
exit 0
|
|
fi
|
|
|
|
echo "wkhtmltopdf not found, installing..."
|
|
|
|
# Detect OS
|
|
if [ -f /etc/os-release ]; then
|
|
. /etc/os-release
|
|
OS=$ID
|
|
VERSION=$VERSION_ID
|
|
echo "Detected OS: $OS $VERSION"
|
|
else
|
|
echo "Unable to detect OS, assuming Ubuntu/Debian"
|
|
OS="ubuntu"
|
|
fi
|
|
|
|
# Install based on OS
|
|
if [[ "$OS" == "ubuntu" || "$OS" == "debian" ]]; then
|
|
echo "Installing on Ubuntu/Debian..."
|
|
sudo apt-get update
|
|
sudo apt-get install -y wkhtmltopdf
|
|
elif [[ "$OS" == "centos" || "$OS" == "rhel" || "$OS" == "fedora" ]]; then
|
|
echo "Installing on CentOS/RHEL/Fedora..."
|
|
sudo yum install -y wkhtmltopdf
|
|
elif [[ "$OS" == "alpine" ]]; then
|
|
echo "Installing on Alpine..."
|
|
apk add --no-cache wkhtmltopdf
|
|
else
|
|
echo "Unsupported OS: $OS"
|
|
echo "Please install wkhtmltopdf manually."
|
|
exit 1
|
|
fi
|
|
|
|
# Verify installation
|
|
if command -v wkhtmltopdf &> /dev/null; then
|
|
echo "wkhtmltopdf installed successfully at $(which wkhtmltopdf)"
|
|
wkhtmltopdf --version
|
|
exit 0
|
|
else
|
|
echo "wkhtmltopdf installation failed."
|
|
echo "You may need to install it manually from https://wkhtmltopdf.org/downloads.html"
|
|
exit 1
|
|
fi |