1
0
mirror of https://github.com/oupala/apaxy.git synced 2025-08-25 01:16:16 +02:00

Merge pull request #124 from jordanbancino/develop

feat: add install script with instructions
This commit is contained in:
oupala
2019-05-20 13:29:16 +02:00
committed by GitHub
12 changed files with 332 additions and 71 deletions

View File

@@ -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
<script src=/{FOLDERNAME}/theme/apaxy.js></script>
<script src={FOLDERNAME}/theme/apaxy.js></script>
```
Should be changed to...
@@ -60,7 +77,7 @@ Should be changed to...
<script src=/share/theme/apaxy.js></script>
```
* 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.

200
apaxy-configure.sh Normal file
View File

@@ -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 <<EOF
$(basename "${0}") configure apaxy according to your local paths and configuration.
It can either configure apaxy according to your local paths and configuration bu it can also install the required files in your http server path.
EOF
displayUsage
cat <<EOF
Available optionnal parameters are :
-h - display help
-d - set path/to/dir/ directory where apaxy will be installed on the filesystem
-w - set path/to/dir/ directory where apaxy will be available on the httpd server
-ll - set the log level
-lf - set the log file
EOF
}
###
# display usage
##
displayUsage () {
cat <<EOF
usage - $(basename "${0}") [-h] [-d path/to/dir/] [-w path/to/dir/] [-ll logLevel] [-lf logFile]
EOF
}
###
# log a message
#
# @global $logLevel the log level
# @global $logFile the log file
# @param $1 the log level of the message
# @param $2 the log message
##
log () {
local paramLogLevel="${1}"
local paramLogMessage="${2}"
# shellcheck disable=SC2155
local logDate="$(date +%H:%M:%S)"
local logMessage="[${logDate}] ${paramLogMessage}"
if [ "${paramLogLevel}" -le "${logLevel}" ]
then
echo "${logMessage}"
fi
if [ ! -z "${logFile}" ]
then
echo "${logMessage}" >> "${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}"

44
apaxy.config Executable file
View File

@@ -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=""

View File

@@ -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

View File

@@ -6,7 +6,7 @@
<title>Error 400</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -6,7 +6,7 @@
<title>Error 403</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -6,7 +6,7 @@
<title>Error 404</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -6,7 +6,7 @@
<title>Error 408</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -6,7 +6,7 @@
<title>Error 500</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -6,7 +6,7 @@
<title>Error 502</title>
<link rel="shortcut icon" href="img/icon.png">
<!-- Stylesheets -->
<link rel="stylesheet" href="/{FOLDERNAME}/theme/style.css" />
<link rel="stylesheet" href="{FOLDERNAME}/theme/style.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
</head>
<body class="fadeDown">

View File

@@ -7,4 +7,4 @@
<div class="footer">
Apaxy by <a href="https://twitter.com/adamwhitcroft">@adamwhitcroft</a>
</div><!--/.footer-->
<script src=/{FOLDERNAME}/theme/apaxy.js></script>
<script src={FOLDERNAME}/theme/apaxy.js></script>