diff --git a/README.md b/README.md index 50b8052..480e9fb 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,23 @@ _Sadly, visual style is all you can work with. It's not possible to alter the ge Apaxy requires an Apache(2.2.11+) enabled HTTP server. +### Quick Start +If you would like, you can automate the installation of Apaxy with the included `apaxy-configure.sh` script. + +To get started, first open `apaxy.config` in your favorite editor: + + $ vim apaxy.config + +Edit the WEB_ROOT and INSTALL_DIRECTORY variables to correspond to your server's settings, then save and exit. + +Then run the configuration script as a user that can write to the install directory. With Apache, this would be the `www-data` user: + + $ sudo -u www-data ./apaxy-configure.sh + +The files will be copied to the web server directory, and modified automatically based on the settings specified. + +### Manual Install + Let's assume you have a folder named `share` in your server root directory (the path thus being `http://mywebsite.com/share`) that you'd like to use as your listing directory: * [Download](https://github.com/AdamWhitcroft/Apaxy/archive/master.zip) and unzip Apaxy @@ -46,7 +63,7 @@ Should be changed to... AddIcon /share/theme/icons/gif.png .gif ``` -* Edit `footer.html`, `400.html`, `403.html`, `404.html`, `408.html`, `500.html`, `502.html` (now in the `/share/theme` folder) and update all instances of paths marked with *{FOLDERNAME}* to point to your site root. +* Edit `footer.html` (now in the `/share/theme` folder) and update all instances of paths marked with *{FOLDERNAME}* to point to your site root. So... diff --git a/apaxy-configure.sh b/apaxy-configure.sh new file mode 100755 index 0000000..a1712a8 --- /dev/null +++ b/apaxy-configure.sh @@ -0,0 +1,69 @@ +#!/bin/bash +echo "Apaxy Configurator - by Jordan Bancino" +echo "Checking configuration..." + +CONFIG="apaxy.config" + +if [ -f "$CONFIG" ]; then + . "$CONFIG" +else + echo "Apaxy configuration not found! Please restore or create the configuration file: $CONFIG" + exit 1 +fi + +if [ -v INSTALL_DIRECTORY ] && [ -v WEB_ROOT ]; then + echo "- Configuring Apaxy for use in directory: $INSTALL_DIRECTORY (Web root: $WEB_ROOT)" + mkdir -p "$WEB_ROOT$INSTALL_DIRECTORY" + if [ ! -w "$WEB_ROOT$INSTALL_DIRECTORY" ] || [ ! -d "$WEB_ROOT$INSTALL_DIRECTORY" ]; then + echo "Directory does not exist or is not writable by the current user: $WEB_ROOT$INSTALL_DIRECTORY" + exit 1 + fi +else + echo "No directory specified! Please define the INSTALL_DIRECTORY and WEB_ROOT variables in $CONFIG" + exit 1 +fi + +echo "Copying files to web root..." +cp -r . "$WEB_ROOT$INSTALL_DIRECTORY" +cd "$WEB_ROOT$INSTALL_DIRECTORY" + +if [ -v HTACCESS ]; then + if [ -f "$HTACCESS" ]; then + echo "- Using template: $HTACCESS to generate configuration" + else + echo "Configuration template does not exist! Please specify an existing configuration template in $CONFIG" + exit 1 + fi +else + echo "No configuration template specified. Please define the HTACCESS variable in $CONFIG" + exit 1 +fi + +if [ ! -v TEMPLATE_VAR_FOLDERNAME ]; then + echo "No foldername variable defined. Please define the TEMPLATE_VAR_FOLDERNAME variable in $CONFIG" + exit +fi + +echo "Configuring..." +echo "- Generating .htaccess..." +sed "s|$TEMPLATE_VAR_FOLDERNAME|$INSTALL_DIRECTORY/apaxy/|g" <"$HTACCESS" >"$HTACCESS_OUTPUT" + +echo "- Setting variables in documents..." +# find all the HTML files and replace the variable in them. +# This will automatically take care of the error pages, headers and +# footers. +FILES=$(find -name "*.html") +while read -r file; do + sed -i "s|$TEMPLATE_VAR_FOLDERNAME|$INSTALL_DIRECTORY/apaxy/|g" "$file" +done <<< "$FILES" + +if [ -v THEME_HTACCESS_IN ] && [ -v THEME_HTACCESS_OUT ]; then + echo "- Activating theme configuration..." + mv "$THEME_HTACCESS_IN" "$THEME_HTACCESS_OUT" +fi + +# TODO: +# - Implement any other options we want here + +echo "Done." +exit 0 diff --git a/apaxy.config b/apaxy.config new file mode 100755 index 0000000..0aa6176 --- /dev/null +++ b/apaxy.config @@ -0,0 +1,45 @@ +# Apaxy Configuration - by Jordan Bancino +# (C) 2018 Jordan Bancino +# +# Use "apaxy-configure.sh" to configure Apaxy after adjusting the needed values. +# +# NOTICE: Directories can be absolute or relative, but make sure they start with either "/", "../", or "./", +# and DO NOT leave a trailing slash. +# Good: "/var/www/html" <- Starts with "/", does not have trailing slash +# Bad : "var/www/html" <- Does not start with "/", "./", or "../" +# Good: "./var/www/html" <- Starts with "./", does not have trailing slash +# Bad : "/var/www/html/" <- Has trailing slash + +# +# GENERAL CONFIGURATION +# + +# The directory to configure Apaxy for use in. This is relative to the web server root, and contains the "theme" folder. +# For instance: "http://website.com/share" would make this value "/share", where "/share/apaxy/theme" is the theme directory +INSTALL_DIRECTORY="/dev/apaxy-deploy" + +# The web root where the server serves documents. Default for Apache is /var/www/html +WEB_ROOT="/var/www/html" + +# The output .htaccess file. +# Place the file in the root of the directory in which you are applying apaxy. +HTACCESS_OUTPUT="$WEB_ROOT$INSTALL_DIRECTORY/.htaccess" + +# +# ADVANCED CONFIGURATION +# Normal users: Do not modify below this line. +# + +# The htaccess template to run the configuration on. +# Do not change this value for a regular installation of Apaxy. +HTACCESS="apaxy/htaccess.txt" + +# The theme config for Apaxy. IN will be renamed to OUT. +# There should be no reason to change this in most cases. +THEME_HTACCESS_IN="apaxy/theme/htaccess.txt" +THEME_HTACCESS_OUT="apaxy/theme/.htaccess" + + +# The variable in the htaccess and footer templates. +# Do not change this value unless you use a different template with a different variable. +TEMPLATE_VAR_FOLDERNAME="/{FOLDERNAME}/"