added support for docker to run with a certain PUID and PGID
This commit is contained in:
@@ -1,25 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
PKGDIR="/opt/mykb"
|
||||
DBDIR="$PKGDIR/db"
|
||||
KBDIR="$PKGDIR/kb"
|
||||
CONFDIR="$PKGDIR/config"
|
||||
|
||||
if [ -d "/db" ];then
|
||||
rm -rf /opt/mykb/db
|
||||
ln -s /db /opt/mykb/db
|
||||
rm -rf $DBDIR
|
||||
ln -s /db $DBDIR
|
||||
DBDIR="/db"
|
||||
fi
|
||||
|
||||
if [ -d "/kb" ];then
|
||||
rm -rf /opt/mykb/kb
|
||||
ln -s /kb /opt/mykb/kb
|
||||
KBDIR="/kb"
|
||||
fi
|
||||
|
||||
if [ -d "/config" ];then
|
||||
for i in /opt/mykb/config/*;do file=${i#/opt/mykb/config/}; if [ ! -f "/config/$file" ];then cp "$i" "/config/$file"; fi;done
|
||||
rm -rf /opt/mykb/config
|
||||
ln -s /config /opt/mykb/config
|
||||
for i in $CONFDIR/*;do file=${i#/opt/mykb/config/}; if [ ! -f "/config/$file" ];then cp "$i" "/config/$file"; fi;done
|
||||
rm -rf $CONFDIR
|
||||
ln -s /config $CONFDIR
|
||||
CONFDIR="/config"
|
||||
fi
|
||||
|
||||
git config --global user.email "$GIT_EMAIL"
|
||||
git config --global user.name "$GIT_NAME"
|
||||
|
||||
cd /opt/mykb
|
||||
echo $PWD
|
||||
NODE_ENV=production node ./genSecret.js
|
||||
yarn start
|
||||
export NODE_ENV=production
|
||||
|
||||
if [ -z "$PUID" ];then
|
||||
echo 'no PUID set running as default user'
|
||||
node ./genSecret.js && node ./src
|
||||
else
|
||||
echo 'chowning files'
|
||||
DIRS=($KBDIR $DBDIR $CONFDIR)
|
||||
for dir in ${DIRS[@]};do chown "$PUID:$PGID" $dir;done
|
||||
chown "$PUID:$PGID" -R $CONFDIR
|
||||
s6-setuidgid "$PUID:$PGID" node ./genSecret.js
|
||||
s6-setuidgid "$PUID:$PGID" node ./src
|
||||
fi
|
||||
Reference in New Issue
Block a user