diff --git a/README.md b/README.md index 50b8052..68afcb4 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 @@ -37,7 +54,7 @@ Let's assume you have a folder named `share` in your server root directory (the So... ```ApacheConf -AddIcon /{FOLDERNAME}/theme/icons/gif.png .gif +AddIcon {FOLDERNAME}/theme/icons/gif.png .gif ``` Should be changed to... @@ -46,12 +63,12 @@ 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`, along with all the other `html` documents (in the `/share/theme` folder) and update all instances of paths marked with *{FOLDERNAME}* to point to your site root. So... ```html - + ``` Should be changed to... @@ -60,7 +77,7 @@ Should be changed to... ``` -* Once done, rename `htaccess.txt` to `.htaccess` in both the `/share` and `/share/theme` folders. +* Once done, rename `htaccess.txt` to `.htaccess` in the `/share` directory. * [Treat yo'self](http://25.media.tumblr.com/tumblr_lw7q28y0Mz1qanm80o1_500.gif), you're done. ## Docker images @@ -83,10 +100,10 @@ Edit these as you would any other HTML or CSS file. Adding your own icons is a little more involved. You'll need to edit the main Apaxy `.htaccess` file. Look for the following as an example: ```ApacheConf -AddIcon /{FOLDERNAME}/theme/icons/gif.png .gif +AddIcon {FOLDERNAME}/theme/icons/gif.png .gif ``` -The above rule will assign an icon named `gif.png` from the directory `/{FOLDERNAME}/theme/icons/` to any file with the `.gif` extension. +The above rule will assign an icon named `gif.png` from the directory `{FOLDERNAME}/theme/icons/` to any file with the `.gif` extension. This URL path is relative to your site's root. diff --git a/apaxy-configure.sh b/apaxy-configure.sh new file mode 100644 index 0000000..95cefe2 --- /dev/null +++ b/apaxy-configure.sh @@ -0,0 +1,200 @@ +#!/bin/bash +# +# apaxy configurator +# v0.2 +# configure apaxy according to your local paths and configuration +# author : Jordan Bancino and Ploc +# contact : jordan [@] bancino.net +# licence : GPLv3 + +# enabling strict mode +# -e - exit immediatly on error (disable with "+e" when an error can happens, then enable it again with "-e") +# -u - undefined variables are forbidden (enable this option after getting parameters from $1 $2...) see below +# -o pipefail - find error return code inside piped commands +# IFS - set strong internal field separator +set -eo pipefail +IFS=$'\n\t' + +# default config +defaultLogLevel=2 +defaultLogFile="$(basename "${0}" .sh).log" +defaultApacheWebRootPath="/var/www/html" +defaultInstallWebPath="" + +# functions + +### + # display help + ## +displayHelp () { + cat <> "${logFile}" + fi +} + +# getting parameters value from config file (can be overloaded by cli values) +workingDirectory=$(dirname "$0") + +if [ -f "${workingDirectory}/apaxy.config" ]; then + # shellcheck source=apaxy.config + source "${workingDirectory}/apaxy.config" +else + log 1 "ERROR - apaxy configuration not found, please restore or create the configuration file apaxy.config" + exit 1 +fi + +# getting parameters value from cli (can overload config file values) +while [ "$#" -ge 1 ] ; do + case "${1}" in + -h|--help) # display help + displayHelp + exit 0 + ;; + -d) # set path/to/dir/ directory where apaxy will be available on the httpd server + shiftStep=2 + apacheWebRootPath="${2}" + ;; + -w) # set path/to/dir/ directory where apaxy will be installed on the filesystem + shiftStep=2 + installWebPath="${2}" + ;; + -ll) # set the log level + shiftStep=2 + logLevel="${2}" + ;; + -lf) # set the log file + shiftStep=2 + logFile="${2}" + ;; + *) + displayUsage + exit 2 + ;; + esac + + if [ "$#" -ge "${shiftStep}" ] + then + shift "${shiftStep}" + else + log 1 "ERROR - invalid number of arguments" + exit 3 + fi +done + +# setting parameters value +if [ -z "${apacheWebRootPath}" ] +then + apacheWebRootPath="${defaultApacheWebRootPath}" +fi + +if [ -z "${installWebPath}" ] +then + installWebPath="${defaultInstallWebPath}" +fi + +if [ -n "${apacheWebRootPath}" ] && [ -z "${installWebPath}" ] +then + installDir="${apacheWebRootPath}" +else + installDir="${apacheWebRootPath}${installWebPath}" +fi + +if [ -z "${logLevel}" ] +then + logLevel="${defaultLogLevel}" +fi + +if [ -z "${logFile}" ] +then + logFile="${workingDirectory}/${defaultLogFile}" +fi + +# enabling strict mode +# -u - undefined variables are forbidden (enable this option after getting parameters from $1 $2...) +set -u + +# checking parameters value +if [ ! -d "$(dirname "${logFile}")" ] +then + log 1 "ERROR - $(dirname "${logFile}") does not exist" + exit 4 +fi + +# script +log 1 "- creating install directory ${installDir}" +mkdir -p "${installDir}" +if [ ! -d "${installDir}" ] || [ ! -w "${installDir}" ]; then + log 1 "ERROR - install directory ${installDir} does not exist or is not writable by the current user" + exit 5 +fi + +log 1 "- copying apaxy in install directory" +cp -r apaxy/* "${installDir}/" + +log 1 "- configuring apaxy in install directory" + +log 2 "- generating htaccess" +sed "s|{FOLDERNAME}|${installWebPath}|g" < "${installDir}/htaccess.txt" > "${installDir}/.htaccess" +rm "${installDir}/htaccess.txt" + +# find all the html files and replace the variable in them +# this will automatically take care of the error pages, headers and footers +log 2 "- setting path in html files" +files=$(find ${installDir} -name "*.html") +while read -r file; do + sed -i "s|{FOLDERNAME}|${installWebPath}|g" "${file}" +done <<< "${files}" + +log 2 "- syncing filesystem" +sync +log 1 "- filesystem has been synced and is now consistent" +log 1 "- apaxy has been successfully configured and installed in ${installDir}" diff --git a/apaxy.config b/apaxy.config new file mode 100755 index 0000000..2238029 --- /dev/null +++ b/apaxy.config @@ -0,0 +1,44 @@ +#!/bin/bash +# +# apaxy configurator +# v0.2 +# use "apaxy-configure.sh" to configure apaxy after adjusting the needed values in this file +# author : Jordan Bancino and Ploc +# contact : jordan [@] bancino.net +# licence : GPLv3 + +# default log level on the console (the lower the number is, the less verbose it is) +#defaultLogLevel=2 + +# all log messages are written to log file +#defaultLogFile="apaxy.log" + +# the apache web root path where the server serves documents +# +# default for apache is /var/www/html +# +# note that path should be absolute, so make sure it starts with a "/" +# and DO NOT leave a trailing slash +# +# good: "/var/www/html" <- starts with "/", does not have trailing "/" +# bad : "var/www/html/" <- does not start with "/", have a trailing "/" +# +apacheWebRootPath="/var/www/html" + +# the directory where apaxy will be used (this is relative to the web server root, and contains the "theme" folder) +# +# for instance: "http://example.org/share" would make this value "/share", where "/share/theme" is the theme directory +# +# note that path should be absolute, so make sure it starts with a "/" +# and DO NOT leave a trailing slash +# +# good: "/share" <- starts with "/", does not have trailing "/" +# bad : "share/" <- does not start with "/", has a trailing "/" +# +# by default, apaxy is configured to be installed at the root level of your web server +# +# if you want apaxy to be installed anywhere else, you can set it in the installWebPath variable +# +# installWebPath="/share" +# +installWebPath="" diff --git a/apaxy/htaccess.txt b/apaxy/htaccess.txt index 57e445c..f82cb04 100644 --- a/apaxy/htaccess.txt +++ b/apaxy/htaccess.txt @@ -29,76 +29,76 @@ IndexIgnore .htaccess /theme # AddIcon /share/theme/icons/blank.png ^^BLANKICON^^ # -AddIcon /{FOLDERNAME}/theme/icons/blank.png ^^BLANKICON^^ -AddIcon /{FOLDERNAME}/theme/icons/folder.png ^^DIRECTORY^^ -AddIcon /{FOLDERNAME}/theme/icons/folder-home.png .. +AddIcon {FOLDERNAME}/theme/icons/blank.png ^^BLANKICON^^ +AddIcon {FOLDERNAME}/theme/icons/folder.png ^^DIRECTORY^^ +AddIcon {FOLDERNAME}/theme/icons/folder-home.png .. -AddIconByType (TXT,/{FOLDERNAME}/theme/icons/text.png) text/* -AddIconByType (IMG,/{FOLDERNAME}/theme/icons/image.png) image/* -AddIconByType (SND,/{FOLDERNAME}/theme/icons/audio.png) audio/* -AddIconByType (VID,/{FOLDERNAME}/theme/icons/video.png) video/* +AddIconByType (TXT,{FOLDERNAME}/theme/icons/text.png) text/* +AddIconByType (IMG,{FOLDERNAME}/theme/icons/image.png) image/* +AddIconByType (SND,{FOLDERNAME}/theme/icons/audio.png) audio/* +AddIconByType (VID,{FOLDERNAME}/theme/icons/video.png) video/* # # EXTENSION SPECIFIC ICONS # -AddIcon /{FOLDERNAME}/theme/icons/archive.png .7z .bz2 .cab .gz .tar -AddIcon /{FOLDERNAME}/theme/icons/audio.png .aac .aif .aifc .aiff .ape .au .flac .iff .m4a .mid .mp3 .mpa .ra .wav .wma .f4a .f4b .oga .ogg .xm .it .s3m .mod -AddIcon /{FOLDERNAME}/theme/icons/bin.png .bin .hex -AddIcon /{FOLDERNAME}/theme/icons/bmp.png .bmp -AddIcon /{FOLDERNAME}/theme/icons/c.png .c -AddIcon /{FOLDERNAME}/theme/icons/calc.png .xlsx .xlsm .xltx .xltm .xlam .xlr .xls .csv -AddIcon /{FOLDERNAME}/theme/icons/cd.png .iso -AddIcon /{FOLDERNAME}/theme/icons/cpp.png .cpp -AddIcon /{FOLDERNAME}/theme/icons/css.png .css .sass .scss -AddIcon /{FOLDERNAME}/theme/icons/deb.png .deb -AddIcon /{FOLDERNAME}/theme/icons/doc.png .doc .docx .docm .dot .dotx .dotm .log .msg .odt .pages .rtf .tex .wpd .wps -AddIcon /{FOLDERNAME}/theme/icons/draw.png .svg .svgz -AddIcon /{FOLDERNAME}/theme/icons/eps.png .ai .eps -AddIcon /{FOLDERNAME}/theme/icons/exe.png .exe -AddIcon /{FOLDERNAME}/theme/icons/gif.png .gif -AddIcon /{FOLDERNAME}/theme/icons/h.png .h -AddIcon /{FOLDERNAME}/theme/icons/html.png .html .xhtml .shtml .htm .URL .url -AddIcon /{FOLDERNAME}/theme/icons/ico.png .ico -AddIcon /{FOLDERNAME}/theme/icons/java.png .jar -AddIcon /{FOLDERNAME}/theme/icons/jpg.png .jpg .jpeg .jpe -AddIcon /{FOLDERNAME}/theme/icons/js.png .js .json -AddIcon /{FOLDERNAME}/theme/icons/markdown.png .md -AddIcon /{FOLDERNAME}/theme/icons/package.png .pkg .dmg -AddIcon /{FOLDERNAME}/theme/icons/pdf.png .pdf -AddIcon /{FOLDERNAME}/theme/icons/php.png .php .phtml -AddIcon /{FOLDERNAME}/theme/icons/playlist.png .m3u .m3u8 .pls .pls8 -AddIcon /{FOLDERNAME}/theme/icons/png.png .png -AddIcon /{FOLDERNAME}/theme/icons/ps.png .ps -AddIcon /{FOLDERNAME}/theme/icons/psd.png .psd -AddIcon /{FOLDERNAME}/theme/icons/py.png .py -AddIcon /{FOLDERNAME}/theme/icons/rar.png .rar -AddIcon /{FOLDERNAME}/theme/icons/rb.png .rb -AddIcon /{FOLDERNAME}/theme/icons/rpm.png .rpm -AddIcon /{FOLDERNAME}/theme/icons/rss.png .rss -AddIcon /{FOLDERNAME}/theme/icons/script.png .bat .cmd .sh -AddIcon /{FOLDERNAME}/theme/icons/sql.png .sql -AddIcon /{FOLDERNAME}/theme/icons/tiff.png .tiff .tif -AddIcon /{FOLDERNAME}/theme/icons/text.png .txt .nfo .epub .mobi .azw -AddIcon /{FOLDERNAME}/theme/icons/video.png .asf .asx .avi .flv .mkv .mov .mp4 .mpg .rm .srt .swf .vob .wmv .m4v .f4v .f4p .ogv -AddIcon /{FOLDERNAME}/theme/icons/xml.png .xml -AddIcon /{FOLDERNAME}/theme/icons/zip.png .zip -DefaultIcon /{FOLDERNAME}/theme/icons/default.png +AddIcon {FOLDERNAME}/theme/icons/archive.png .7z .bz2 .cab .gz .tar +AddIcon {FOLDERNAME}/theme/icons/audio.png .aac .aif .aifc .aiff .ape .au .flac .iff .m4a .mid .mp3 .mpa .ra .wav .wma .f4a .f4b .oga .ogg .xm .it .s3m .mod +AddIcon {FOLDERNAME}/theme/icons/bin.png .bin .hex +AddIcon {FOLDERNAME}/theme/icons/bmp.png .bmp +AddIcon {FOLDERNAME}/theme/icons/c.png .c +AddIcon {FOLDERNAME}/theme/icons/calc.png .xlsx .xlsm .xltx .xltm .xlam .xlr .xls .csv +AddIcon {FOLDERNAME}/theme/icons/cd.png .iso +AddIcon {FOLDERNAME}/theme/icons/cpp.png .cpp +AddIcon {FOLDERNAME}/theme/icons/css.png .css .sass .scss +AddIcon {FOLDERNAME}/theme/icons/deb.png .deb +AddIcon {FOLDERNAME}/theme/icons/doc.png .doc .docx .docm .dot .dotx .dotm .log .msg .odt .pages .rtf .tex .wpd .wps +AddIcon {FOLDERNAME}/theme/icons/draw.png .svg .svgz +AddIcon {FOLDERNAME}/theme/icons/eps.png .ai .eps +AddIcon {FOLDERNAME}/theme/icons/exe.png .exe +AddIcon {FOLDERNAME}/theme/icons/gif.png .gif +AddIcon {FOLDERNAME}/theme/icons/h.png .h +AddIcon {FOLDERNAME}/theme/icons/html.png .html .xhtml .shtml .htm .URL .url +AddIcon {FOLDERNAME}/theme/icons/ico.png .ico +AddIcon {FOLDERNAME}/theme/icons/java.png .jar +AddIcon {FOLDERNAME}/theme/icons/jpg.png .jpg .jpeg .jpe +AddIcon {FOLDERNAME}/theme/icons/js.png .js .json +AddIcon {FOLDERNAME}/theme/icons/markdown.png .md +AddIcon {FOLDERNAME}/theme/icons/package.png .pkg .dmg +AddIcon {FOLDERNAME}/theme/icons/pdf.png .pdf +AddIcon {FOLDERNAME}/theme/icons/php.png .php .phtml +AddIcon {FOLDERNAME}/theme/icons/playlist.png .m3u .m3u8 .pls .pls8 +AddIcon {FOLDERNAME}/theme/icons/png.png .png +AddIcon {FOLDERNAME}/theme/icons/ps.png .ps +AddIcon {FOLDERNAME}/theme/icons/psd.png .psd +AddIcon {FOLDERNAME}/theme/icons/py.png .py +AddIcon {FOLDERNAME}/theme/icons/rar.png .rar +AddIcon {FOLDERNAME}/theme/icons/rb.png .rb +AddIcon {FOLDERNAME}/theme/icons/rpm.png .rpm +AddIcon {FOLDERNAME}/theme/icons/rss.png .rss +AddIcon {FOLDERNAME}/theme/icons/script.png .bat .cmd .sh +AddIcon {FOLDERNAME}/theme/icons/sql.png .sql +AddIcon {FOLDERNAME}/theme/icons/tiff.png .tiff .tif +AddIcon {FOLDERNAME}/theme/icons/text.png .txt .nfo .epub .mobi .azw +AddIcon {FOLDERNAME}/theme/icons/video.png .asf .asx .avi .flv .mkv .mov .mp4 .mpg .rm .srt .swf .vob .wmv .m4v .f4v .f4p .ogv +AddIcon {FOLDERNAME}/theme/icons/xml.png .xml +AddIcon {FOLDERNAME}/theme/icons/zip.png .zip +DefaultIcon {FOLDERNAME}/theme/icons/default.png # # THEME FILES # -HeaderName /{FOLDERNAME}/theme/header.html -ReadmeName /{FOLDERNAME}/theme/footer.html -IndexStyleSheet "/{FOLDERNAME}/theme/style.css" +HeaderName {FOLDERNAME}/theme/header.html +ReadmeName {FOLDERNAME}/theme/footer.html +IndexStyleSheet "{FOLDERNAME}/theme/style.css" # # ERROR PAGES # -ErrorDocument 400 /{FOLDERNAME}/theme/400.html -ErrorDocument 403 /{FOLDERNAME}/theme/403.html -ErrorDocument 404 /{FOLDERNAME}/theme/404.html -ErrorDocument 408 /{FOLDERNAME}/theme/408.html -ErrorDocument 500 /{FOLDERNAME}/theme/500.html -ErrorDocument 502 /{FOLDERNAME}/theme/502.html +ErrorDocument 400 {FOLDERNAME}/theme/400.html +ErrorDocument 403 {FOLDERNAME}/theme/403.html +ErrorDocument 404 {FOLDERNAME}/theme/404.html +ErrorDocument 408 {FOLDERNAME}/theme/408.html +ErrorDocument 500 {FOLDERNAME}/theme/500.html +ErrorDocument 502 {FOLDERNAME}/theme/502.html diff --git a/apaxy/theme/htaccess.txt b/apaxy/theme/.htaccess similarity index 100% rename from apaxy/theme/htaccess.txt rename to apaxy/theme/.htaccess diff --git a/apaxy/theme/400.html b/apaxy/theme/400.html index a841e66..6204e63 100644 --- a/apaxy/theme/400.html +++ b/apaxy/theme/400.html @@ -6,7 +6,7 @@ Error 400 - + diff --git a/apaxy/theme/403.html b/apaxy/theme/403.html index 519fe4f..645952d 100644 --- a/apaxy/theme/403.html +++ b/apaxy/theme/403.html @@ -6,7 +6,7 @@ Error 403 - + diff --git a/apaxy/theme/404.html b/apaxy/theme/404.html index 9402c0e..f0725d4 100644 --- a/apaxy/theme/404.html +++ b/apaxy/theme/404.html @@ -6,7 +6,7 @@ Error 404 - + diff --git a/apaxy/theme/408.html b/apaxy/theme/408.html index ed0fd62..1cff69f 100644 --- a/apaxy/theme/408.html +++ b/apaxy/theme/408.html @@ -6,7 +6,7 @@ Error 408 - + diff --git a/apaxy/theme/500.html b/apaxy/theme/500.html index b14397d..f07c671 100644 --- a/apaxy/theme/500.html +++ b/apaxy/theme/500.html @@ -6,7 +6,7 @@ Error 500 - + diff --git a/apaxy/theme/502.html b/apaxy/theme/502.html index 155a731..12a7d15 100644 --- a/apaxy/theme/502.html +++ b/apaxy/theme/502.html @@ -6,7 +6,7 @@ Error 502 - + diff --git a/apaxy/theme/footer.html b/apaxy/theme/footer.html index a149eea..6cd77b8 100644 --- a/apaxy/theme/footer.html +++ b/apaxy/theme/footer.html @@ -7,4 +7,4 @@ - +