From eed13c1b587c292f86d4b302918418ce78637126 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 31 Aug 2021 08:21:42 +0200 Subject: Create a new database --- Makefile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 72046f0..ab4165e 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,33 @@ -DIR_INSTALL_PATH=/usr/share/dfr/ -DIR_BIN=/usr/sbin/ +DIR_INSTALL_PATH=/usr/share/dfr +DIR_BIN=/usr/sbin install: + # Testing root + @[ "$(shell id -u)" = 0 ] || echo "You *may need root* to run that target" + @[ ! "$(shell id -u)" = 0 ] || echo "You are root" + + # Install to ${DIR_INSTALL_PATH} mkdir -p ${DIR_INSTALL_PATH} - # Copy everything to ${DIR_INSTALL_PATH} - cp -u *.py ${DIR_INSTALL_PATH} + @ echo '' + # Copy code then assets + cp -u *.py ${DIR_INSTALL_PATH}/ cp -r download ${DIR_INSTALL_PATH}/download cp -r assets ${DIR_INSTALL_PATH}/assets + @[ -f frwiktionary-latest-pages-meta-current.xml.bz2 ] && \ + cp -u frwiktionary-latest-pages-meta-current.xml.bz2 ${DIR_INSTALL_PATH}/ # - # Disabled DEBUG to production + # Disabled DEBUG in production sed -i 's/DEBUG = True/DEBUG = False/' ${DIR_INSTALL_PATH}/*.py - # Get the external assets - cd ${DIR_INSTALL_PATH}; python ${DIR_INSTALL_PATH}/download/download.py -d -o "${DIR_INSTALL_PATH}/assets/dicofr.db" + # Get the external assets if needed + cd ${DIR_INSTALL_PATH}; python ${DIR_INSTALL_PATH}/download/download.py -d -o "${DIR_INSTALL_PATH}/assets/dfr.db" # Set permission and install command - chmod +x ${DIR_INSTALL_PATH}/dicofr.py || sudo chmod +x ${DIR_INSTALL_PATH}/dicofr.py - ln -s ${DIR_INSTALL_PATH}/dicofr.py ${DIR_BIN}/dfr || sudo ln -s ${DIR_INSTALL_PATH}/dicofr.py ${DIR_BIN}/dfr - chmod +x ${DIR_BIN}/dfr || sudo chmod +x ${DIR_BIN}/dfr + chmod +x ${DIR_INSTALL_PATH}/dicofr.py + # delete symlink if it exists + [ -h ${DIR_BIN}/dfr ] && unlink ${DIR_BIN}/dfr + # create it + ln -s ${DIR_INSTALL_PATH}/dicofr.py ${DIR_BIN}/dfr + chmod +x ${DIR_BIN}/dfr + @echo 'Enjoy dfr !' uninstall: rm -R ${DIR_INSTALL_PATH} -- cgit v1.3-2-g11bf