use makefile for configuration

This commit is contained in:
matth@ultra 2024-09-01 19:41:34 +02:00
parent bc0661374f
commit e6a41dbd9c
2 changed files with 71 additions and 16 deletions

View File

@ -1,23 +1,71 @@
TESTDIR = test
# CONFIGURE at least ROOT_DIR and INSTALL_DIR
# Absolute path to the directory containing all image directories as well as the staging directory
# MUST HAVE A TRAILING SLASH
# eg: ROOT_DIR = /data/images
ROOT_DIR = /tmp/gimp/
# The URI at which the ROOT_DIR will be served
# MUST HAVE A TRAILING SLASH
ROOT_PATH = /images/
# Path of the directory containing all the files to be sorted, relative to ROOT_DIR
# eg: STAGING_DIR = .sort
STAGING_DIR = .sort
# Absolute path to the directory into which the application files will be installed
# eg: INSTALL_DIR = /www/imgsort2
INSTALL_DIR = /tmp/imgsort2
# DO NOT CHANGE ANYTHING HERE
ifndef ROOT_DIR
$(error Edit this Makefile and set the ROOT_DIR variable)
endif
ifndef INSTALL_DIR
$(error Edit this Makefile and set the INSTALL_DIR variable)
endif
ifndef STAGING_DIR
$(error Edit this Makefile and set the STAGING_DIR variable)
endif
ifndef ROOT_PATH
$(error Edit this Makefile and set the STAGING_DIR variable)
endif
INSTALL_FLS = config.html config.js index.html index.js imgsort.php style.css
SRC_DIR = src
_SRC_FLS = config.html config.js index.html index.js imgsort.php style.css
SRC_FLS = $(foreach f,$(_SRC_FLS),$(SRC_DIR)/$(f))
INSTALL_FLS = $(foreach f,$(_SRC_FLS),$(INSTALL_DIR)/$(f))
SASS_CMD = sass --color --load-path=src/sass
.PHONY: install start stop test php
install:
ifndef DEST
$(error Usage: `make install DEST=/installation/directory`)
endif
mkdir -p $(DEST)
install -m 0744 $(foreach f,$(INSTALL_FLS),$(SRC_DIR)/$(f)) $(DEST)
default: css
.PHONY: clean install stop test php css
install: $(INSTALL_FLS) imgsort2-nginx.conf imgsort2-php-fpm.conf
$(INSTALL_DIR)/%.php: $(SRC_DIR)/%.php
sed 's|$$rootDir = .*|$$rootDir = "$(ROOT_DIR)";|; s|$$rootPath = .*|$$rootPath = "$(ROOT_PATH)"|; s|$$stagingDirName = .*|$$stagingDirName = "$(STAGING_DIR)";|' @< > $@
chmod 0744 $@
$(INSTALL_DIR)/%: $(SRC_DIR)/%
install -m 0744 $< $@
%.conf: $(SRC_DIR)/%.conf
sed 's|root = .*|$$root = $(INSTALL_DIR);|; s|location /images/|location $(ROOT_PATH)|; s|$$alias = .*|alias = $(ROOT_DIR);|' @< > $@
chmod 0744 $@
$(SED_COMMAND) $< > $@
clean:
rm $(INSTALL_FLS)
# testing
php:
php -S localhost:8000 -t . &
@# firefox http://localhost:8000/src/index.html
firefox http://localhost:8000/src/index.html
stop:
-killall php
@ -26,7 +74,10 @@ css:
$(SASS_CMD) --no-indented src/sass/main.sass src/style.css
TESTDIR = images
# Create a image directory for testing.
# This should work with the default configuration
test:
-@rm -r $(TESTDIR)
-@mkdir -p $(TESTDIR) $(TESTDIR)/staging $(TESTDIR)/dest1 $(TESTDIR)/dest2 $(TESTDIR)/dest3
-@cp testres/* $(TESTDIR)/staging
-@mkdir -p $(TESTDIR) $(TESTDIR)/.sort
-@cp resources/* $(TESTDIR)/.sort

View File

@ -19,10 +19,14 @@ The web interface has mobile optimizations, letting you sort images/files on the
## Installation
You need a *php* enabled web server, for example *nginx* with *php-fpm*.
To Install the app files in `/www/imgsort2`, use `make install DEST=/www/imgsort2`.
The web server needs to serve the app files as well as the directory containg all images, called `rootDir`.
You need to configure the `$rootDir` and `$rootPath` as well as the `$stagingDirName` accordingly in the `imgsort.php` file.
Configure the `Makefile` by setting the
- `ROOT_DIR` to the directory containg all images
- `INSTALL_DIR` to the directory that should contain the app files
If you a using nextcloud, make sure to have the `rootDir` directory as an "external" storage media and not in the main nextcloud `data` directory.
Then, run `make install` (with sufficent permissions for `INSTALL_DIR`) to install the application files.
This will also create a `imgsort2-nginx.conf` and `imgsort2-php-fpm.conf` in the current directory, which you
can use as basis for your web server and php configuration.
If you a using nextcloud, make sure to have directory set as `ROOT_DIR` as an **external** storage media and not in the main nextcloud `data` directory.
**The app has no authentication system. Only expose it locally or use something like nginx basic auth to restrict access!**