#!/bin/bash

echo "[cwa-set-perms] Recursively setting ownership of everything in /config, /calibre-library, /app/calibre-web-automated to abc:abc..."

chown -R abc:abc /config

if [[ $? == 0 ]]
then
    echo "[cwa-set-perms] Successfully set permissions for '/config'!"
elif [[ $? > 0 ]]
then
    echo "[cwa-set-perms] Service could not successfully set permissions for '/config' (see errors above)."
fi

chown -R abc:abc /calibre-library
    
if [[ $? == 0 ]]
then
    echo "[cwa-set-perms] Successfully set permissions for '/calibre-library'!"
elif [[ $? > 0 ]]
then
    echo "[cwa-set-perms] Service could not successfully set permissions for '/calibre-library' (see errors above)."
fi

chown -R abc:abc /app/calibre-web-automated

if [[ $? == 0 ]]
then
    echo "[cwa-set-perms] Successfully set permissions for '/app/calibre-web-automated'!"
elif [[ $? > 0 ]]
then
    echo "[cwa-set-perms] Service could not successfully set permissions for '/app/calibre-web-automated' (see errors above)."
fi

echo "[cwa-set-perms] Ending service..."