blob: 4dd9a3184f792861e58bc60a4e1e1cfaee55e46f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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}
@ 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}/ || true
#
# Disabled DEBUG in production
sed -i 's/DEBUG = True/DEBUG = False/' ${DIR_INSTALL_PATH}/*.py
# 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}/dfr.py
# delete symlink if it exists
[ -h ${DIR_BIN}/dfr ] && unlink ${DIR_BIN}/dfr
# create it
ln -s ${DIR_INSTALL_PATH}/dfr.py ${DIR_BIN}/dfr
chmod +x ${DIR_BIN}/dfr
@echo 'Enjoy dfr !'
uninstall:
rm -R ${DIR_INSTALL_PATH}
unlink ${DIR_BIN}/dfr
@echo 'Have a nice day ! 👋'
|