2
0
Fork 0
mirror of https://github.com/friendica/docker synced 2024-06-22 12:54:40 +02:00

Fixing travis tests

- deleting `friendica` binary (not usable in docker environments)
- adding the business logic to `entrypoint.sh`
- quiet installation of Friendica (reason for Travis-fails!)
This commit is contained in:
Philipp Holzer 2018-05-20 21:55:54 +02:00
parent c8069b2d54
commit eb7399e6f2
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
25 changed files with 629 additions and 1091 deletions

View file

@ -123,31 +123,19 @@ You can also predefine the following `.htconfig.php` values:
There are differences between the [stable](https://github.com/friendica/docker/tree/master/stable/) and the [develop](https://github.com/friendica/docker/tree/master/develop/) branches.
They have both in common that normally we do not automatically overwrite your working directory with the new version.
Instead you need to explicit run `friendica update` for the node for updating files&database.
Instead you need to explicit run `update` for the node for updating files&database.
## Updating stable
You have to pull the latest image from the hub (`docker pull friendica`).
## Updating develop
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
Instead you can just update your node with `friendica update`.
It will clone the latest Friendica version and copy it to your working directory.
# The `friendica` CLI
To make the usage of the Dockerimages smooth, we created a little CLI.
It wraps the common commands for Friendica and adds new commands.
You can call it with
Instead you can just update your node with executing `update` on the node.
Example:
```console
$ docker exec -ti friendica_running_node friendica <command> \
$ docker exec -ti friendica_running_node update
```
Commands:
- `console` Executes an command in the Friendica console (`bin/console.php` wrapper)
- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper)
- `install` Installs Friendica on a empty environment (gets called automatically during first start)
- `update` Updates Friendica on a **existing** environment
It will clone the latest Friendica version and copy it to your working directory.
# Questions / Issues
If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue.

View file

@ -102,11 +102,9 @@ RUN {\
ENV FRIENDICA_VERSION develop
ENV ADDONS_VERSION develop
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"

View file

@ -80,11 +80,9 @@ RUN {\
ENV FRIENDICA_VERSION develop
ENV ADDONS_VERSION develop
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"

View file

@ -93,11 +93,9 @@ RUN {\
ENV FRIENDICA_VERSION develop
ENV ADDONS_VERSION develop
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"

View file

@ -115,11 +115,9 @@ RUN set -ex; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"

View file

@ -93,11 +93,9 @@ RUN set -ex; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"

View file

@ -106,11 +106,9 @@ RUN set -ex; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz;
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View file

@ -1,172 +0,0 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
# Removing the whole directory first
rm -fr ${dir}/friendica
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
return
}
# executes the Friendica console
console() {
cd ${WORKDIR}
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
php "${WORKDIR}/bin/console.php" $@
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no version found"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
return;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
console "dbstructure update"
}
sendmail() {
if [ ! -f /etc/init.d/sendmail ]; then
# If sendmail isn't installed, exit this method
return
fi
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
echo "Starting sendmail for Mail-Support"
/etc/init.d/sendmail start
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
sendmail) shift; sendmail "$@" ;;
*) friendica_help ;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -1,8 +1,107 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
friendica sendmail
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
exec "$@"
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# executes the Friendica console
console() {
cd $WORKDIR
# Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works)
sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1
}
# If there is no VERSION file or the command is "update", (re-)install Friendica
if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then
installed_version="0.0.0.0"
if [ -f $WORKDIR/VERSION ]; then
installed_version="$(cat $WORKDIR/VERSION)"
fi
if [ "$FRIENDICA_VERSION" = "develop" ]; then
# Removing the whole directory first
rm -fr $SOURCEDIR/friendica
git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1
chmod 777 $SOURCEDIR/friendica/view/smarty3
mkdir $SOURCEDIR/friendica/addon
git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because no version found"
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
if [ "$FRIENDICA_VERSION" = "develop" ]; then
if [ ! -f ${WORKDIR}/bin/composer.phar ]; then
echo "no composer found"
exit 1
fi
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1
fi
if [ ! -f $WORKDIR/.htconfig.php ] &&
[ -f $SOURCEDIR/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr $WORKDIR/view/smarty3/compiled
elif [ "$1" = "update" ]; then
console "dbstructure update"
fi
fi
fi
# Start sendmail if you find it
if [ -f /etc/init.d/sendmail ]; then
line=$(head -n 1 /etc/hosts)
line2=$(echo $line | awk '{print $2}')
echo "$line $line2.localdomain" >> /etc/hosts
nohup /etc/init.d/sendmail start > /dev/null 2>&1 &
fi
exec "$@"