Makefile 1.22 KB
INSTALLDIR                = /var/www
SED_REPLACE_ALL           = sed -i "s/$(1)/$(2)/g" "$(3)"
SED_REPLACE_ALL_PATH      = sed -i "s\#$(1)\#$(2)\#g" "$(3)"
ifndef IP
    ifneq ($(shell ip route | grep "default" | awk '{print $$5; exit}'),)
        IP := $(shell ip route get 1 | awk '{print $$7; exit}')
    else
        IP := 127.0.0.1
    endif
endif
LOCALHOST                ?= ${IP}

D=$(shell find * -type d -print)
F=$(shell find * -type f -not -iname "Makefile" -not -iname "README.md" -print)

install:
	@ cp ./conf/app-conf.json.template ./conf/app-conf.json
	@ $(call SED_REPLACE_ALL_PATH,<pybossa-base-url>,http://${LOCALHOST}/pybossa,./conf/app-conf.json)
	@ $(call SED_REPLACE_ALL_PATH,<wikilibras-api-base-url>,http://${LOCALHOST}:201,./conf/app-conf.json)
	@ $(call SED_REPLACE_ALL_PATH,<db-api-base-url>,http://${LOCALHOST}:200,./conf/app-conf.json)
	@ for d in ${D}; do sudo $(addprefix install -m 775 -p -v -d ${INSTALLDIR}/,$$d); done
	@ for f in ${F}; do sudo $(addprefix install -m 644 -p -v $$f ${INSTALLDIR}/,$$f); done

uninstall:
	@ for f in ${F}; do sudo $(addprefix rm -fv ${INSTALLDIR}/,$$f); done
	@ if [ -d "${INSTALLDIR}" ]; then sudo find ${INSTALLDIR} -type d -empty -print -delete; fi

.PHONY: install uninstall