Skip to content

Commit

Permalink
Merge pull request #29 from am97/fix_owner
Browse files Browse the repository at this point in the history
fix: change owner after initialization
  • Loading branch information
eldy authored Dec 11, 2024
2 parents 48baf43 + 3791bba commit 4d08de2
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 126 deletions.
31 changes: 16 additions & 15 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,6 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"

local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi


echo
echo "*** You can connect to the docker Mariadb with:"
Expand Down
30 changes: 15 additions & 15 deletions images/15.0.3-php7.4/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,6 +407,21 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"

local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
Expand Down
32 changes: 16 additions & 16 deletions images/16.0.5-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,7 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"


local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
echo "sudo docker exec -it nameofwebcontainer-mariadb-1 bash"
Expand Down
32 changes: 16 additions & 16 deletions images/17.0.4-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,7 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"


local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
echo "sudo docker exec -it nameofwebcontainer-mariadb-1 bash"
Expand Down
32 changes: 16 additions & 16 deletions images/18.0.6-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,7 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"


local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
echo "sudo docker exec -it nameofwebcontainer-mariadb-1 bash"
Expand Down
32 changes: 16 additions & 16 deletions images/19.0.4-php8.2/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,7 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"


local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
echo "sudo docker exec -it nameofwebcontainer-mariadb-1 bash"
Expand Down
32 changes: 16 additions & 16 deletions images/20.0.2-php8.2/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ function get_env_value() {
# Function to create directories, create conf.php file and set permissions on files
function initDolibarr()
{
local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ! -d /var/www/documents ]]; then
echo "[INIT] => create volume directory /var/www/documents ..."
mkdir -p /var/www/documents
Expand Down Expand Up @@ -109,16 +104,6 @@ EOF
else
chmod 400 /var/www/html/conf/conf.php
fi

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi
}


Expand Down Expand Up @@ -422,7 +407,22 @@ function run()

# Run scripts before starting
runScripts "before-starting.d"


local CURRENT_UID=$(id -u www-data)
local CURRENT_GID=$(id -g www-data)
usermod -u ${WWW_USER_ID} www-data
groupmod -g ${WWW_GROUP_ID} www-data

if [[ ${CURRENT_UID} -ne ${WWW_USER_ID} || ${CURRENT_GID} -ne ${WWW_GROUP_ID} ]]; then
# Refresh file ownership cause it has changed
echo "[INIT] => As UID / GID have changed from default, update ownership for files in /var/ww ..."
chown -R www-data:www-data /var/www
else
# Reducing load on init : change ownership only for volumes declared in docker
echo "[INIT] => update ownership for files in /var/www/documents ..."
chown -R www-data:www-data /var/www/documents
fi

echo
echo "*** You can connect to the docker Mariadb with:"
echo "sudo docker exec -it nameofwebcontainer-mariadb-1 bash"
Expand Down
Loading

0 comments on commit 4d08de2

Please sign in to comment.