Skip to content

Commit

Permalink
- fixed issue #5 - Unable to create /tmp/Mobi
Browse files Browse the repository at this point in the history
 - fixed issue #6 - Not possible for symlinks to be created
  • Loading branch information
Technosoft2000 committed Jul 23, 2017
1 parent a3c50e1 commit 7c25c49
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**2017-07-23 - v1.1.4**

* fixed issue #5 - Unable to create /tmp/Mobi
* fixed issue #6 - Not possible for symlinks to be created

**2017-06-03 - v1.1.3**

* new base image [technosoft2000/alpine-base:3.6-2](https://hub.docker.com/r/technosoft2000/alpine-base/))
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM technosoft2000/alpine-base:3.6-2
MAINTAINER Technosoft2000 <technosoft2000@gmx.net>
LABEL image.version="1.1.3" \
LABEL image.version="1.1.4" \
image.description="Docker image for Calibre Web, based on docker image of Alpine" \
image.date="2017-06-03" \
image.date="2017-07-27" \
url.docker="https://hub.docker.com/r/technosoft2000/calibre-web" \
url.github="https://github.com/Technosoft2000/docker-calibre-web" \
url.support="https://cytec.us/forum"

# Set basic environment settings
ENV \
# - VERSION: the docker image version (corresponds to the above LABEL image.version)
VERSION="1.1.3" \
VERSION="1.1.4" \

# - PUSER, PGROUP: the APP user and group name
PUSER="calibre" \
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ If you want to know more you can head over to the Calibre Web project site: http

## Updates ##

**2017-06-03 - v1.1.3**
**2017-07-23 - v1.1.4**

* new base image [technosoft2000/alpine-base:3.6-2](https://hub.docker.com/r/technosoft2000/alpine-base/))
* new version allows now usage of group id's __PGID__ < 1000
* added check of write permissions at `/books` to know if symlinks can be created
* fixed issue #5 - Unable to create /tmp/Mobi
* fixed issue #6 - Not possible for symlinks to be created

For previous changes see at [full changelog](CHANGELOG.md).

Expand Down
48 changes: 38 additions & 10 deletions get_or_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,60 @@ ln -s $APP_HOME/kindlegen/kindlegen $APP_HOME/app/vendor/kindlegen
# Use -L to get information about the target of a symlink,
# not the link itself, as pointed out in the comments
DIR=/books
echo "[INFO] Checking permissions of $DIR"

echo "> Output is: $(stat -L -c "%a %G %U" $DIR)"
INFO=( $(stat -L -c "%a %G %U" $DIR) )

PERM=${INFO[0]}
echo "> Permissions: $PERM"

GROUP=${INFO[1]}
echo "> Assigned group: $GROUP"

OWNER=${INFO[2]}
echo "> Assigned owner: $OWNER"

# get the number of digits of PERM; could be 3 or 4
PERMLEN=${#PERM}
if [[ $PERMLEN == 3 ]]; then
# add a precending zero because otherwise the permission checks doesn't work
PERM="0$PERM"
echo "> Using permissons for checks: $PERM"
fi

ACCESS="no"
if ((($PERM & 0002) != 0 )); then
# Everyone has write access
ACCESS="yes"
echo "[INFO] Everyone has write access at $DIR"
echo "> Everyone has write access at $DIR"
elif ((($PERM & 0020) != 0 )); then
# Some group has write access.
# Is user in that group?
gs=( $(groups $USER) )
gs=( $(groups $PUSER) )
for g in "${gs[@]}"; do
echo "[INFO] Check if the group $g has write access at $DIR"
echo "> Check if the group $g has write access at $DIR"
if [[ $GROUP == $g ]]; then
ACCESS="yes"
echo "[INFO] The group $g has write access at $DIR"
echo "> The group $g has write access at $DIR"
break
fi
done
elif ((($PERM & 0200) != 0 )); then
# The owner has write access.
# Does the user own the file?
if [[ $USER == $OWNER ]]; then
if [[ $PUSER == $OWNER ]]; then
ACCESS="yes"
echo "[INFO] The user is the owner and has write access at $DIR"
echo "> The user is the owner and has write access at $DIR"
fi
fi

if [[ $ACCESS == "yes" ]]; then
echo "[INFO] app.db and gdrive.db will be linked into /books"
ln -s /books/app.db "$APP_HOME/app/app.db"
ln -s /books/gdrive.db "$APP_HOME/app/gdrive.db"
echo "[INFO] app.db and gdrive.db will be linked into $DIR"
ln -s $DIR/app.db "$APP_HOME/app/app.db"
ln -s $DIR/gdrive.db "$APP_HOME/app/gdrive.db"
else
echo "[WARNING] no write access at /books - app.db and gdrive.db wont be linked into /books"
echo "[WARNING] No write access at $DIR - app.db and gdrive.db wont be linked into $DIR"
fi

# check if the specified books volume is correct
Expand All @@ -59,3 +76,14 @@ if [ ! -f $CALIBRE_PATH/metadata.db ]; then
echo "> Stopping the container with errorlevel 1"
exit 1
fi

# check if a /tmp directory is available, if not create one
# the /tmp directory is needed by calibre-web/kindlegen to convert books to mobi format
# and maybe for other tasks too
TEMP=/tmp
if [ ! -d "$TEMP" ]; then
echo "[INFO] Creating directory for temporary directories and files: $TEMP"
mkdir $TEMP
echo "[INFO] Change the ownership of $TEMP (including subfolders) to $PUSER:$PGROUP"
chown $PUSER:$PGROUP -R $TEMP
fi

0 comments on commit 7c25c49

Please sign in to comment.