Change to singelton type

This commit is contained in:
Modulos 2017-04-23 08:16:43 +02:00
parent f612965604
commit 8c717540bb
6 changed files with 26 additions and 83 deletions

View file

@ -19,44 +19,22 @@ case "$os_version" in
exit 1 exit 1
;; ;;
esac esac
nextcloud_dir="/$__object_id" nextcloud_url=$(cat "$__object/parameter/url")
if [ ! "$nextcloud_dir" ] if [ ! "${nextcloud_url}" ]
then then
echo "Missing nextcloud directory (object_id)." >&2 echo "Missing nextcloud uri (parameter/url)" >&2
exit 1 exit 1
fi fi
state=$(cat "$__object/parameter/state") nextcloud_version=$(cat "$__object/parameter/version")
exists=$(cat "$__object/explorer/exists") if [ ! "${nextcloud_version}" ]
then
case "$state" in echo "Missing nextcloud version (parameter/version)" >&2
present) exit 1
[ "$exists" = "yes" ] && exit 0 fi
nextcloud_uri="${nextcloud_url}${nextcloud_version}.tar.bz2"
nextcloud_url=$(cat "$__object/parameter/nextcloud-uri") # Download tar ball extract and apply script
if [ ! "${nextcloud_url}" ] # TODO: verify shasum of tar ball
then
echo "Missing nextcloud uri (parameter/nextcloud-uri)" >&2
exit 1
fi
nextcloud_version=$(cat "$__object/parameter/nextcloud-version")
if [ ! "${nextcloud_version}" ]
then
echo "Missing nextcloud version (parameter/nextcloud-version)" >&2
exit 1
fi
nextcloud_uri="${nextcloud_url}${nextcloud_version}.tar.bz2"
cat <<eof
curl -LO ${nextcloud_uri} -o ${nextcloud_dir}/nextcloud.tar.bz2 curl -LO ${nextcloud_uri} -o ${nextcloud_dir}/nextcloud.tar.bz2
tar -C /var/www -xvjf ${nextcloud_dir}/nextcloud.tar.bz2 tar -C /var/www -xvjf ${nextcloud_dir}/nextcloud.tar.bz2
rm ${nextcloud_dir}/nextcloud.tar.bz2 rm ${nextcloud_dir}/nextcloud.tar.bz2
bash ${__object}/files/nextcloud.sh bash ${__object}/files/nextcloud.sh
eof
;;
absent)
# all done in manifest
:
;;
*)
echo "Unknown state: $state" >&2
exit 1
esac

61
manifest Normal file → Executable file
View file

@ -20,52 +20,19 @@ case "$os_version" in
;; ;;
esac esac
nextcloud_dir="/$__object_id" # Install packages
if [ ! "$nextcloud_dir" ] for package in php7.0 php7.0-gd php7.0-json php7.0-pgsql php7.0-curl php7.0-mbstring \
then php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip php7.0-bz2 \
echo "Missing nextcloud directory (object_id)." >&2 postgresql nginx
exit 1 do __package $package --state=present
fi done
state=$(cat "$__object/parameter/state")
exists=$(cat "$__object/explorer/exists")
case "$state" in
present)
if [ "$exists" = "yes" ]
then
echo "${nextcloud_dir} already exists" >&2
exit 0
fi
__package php7.0 --state=present # Nginx
require="__package nginx" __file /etc/nginx/sites-enabled/nextcloud --owner www-data \
--group www-data \
--mode 755 --source "$__type/files/nextcloud.nginx" \
--state exists
# Install PHP # Postgres
for package in php7.0-gd php7.0-json php7.0-pgsql php7.0-curl php7.0-mbstring \ require="__package postgresql" __postgres_database nextcloud --owner nextcloud
php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip php7.0-bz2 require="__package/postgresql" __start_on_boot postgres
do require="__package php7.0" __package $package --state=present
done
# Nginx
__package nginx --state=present
require="__package nginx" __file /etc/nginx/sites-enabled/nextcloud --owner www-data \
--group www-data \
--mode 755 --source "$__type/files/nextcloud.nginx" \
--state exists
# Postgres
__package postgresql --state=present
require="__package postgresql" __postgres_database nextcloud --owner nextcloud
require="__package/postgresql" __start_on_boot postgres
absent)
if [ "$exists" ]
then
__process postgres --state absent \
--stop "service postgres stop" \
--name ".*postgres .*"
__start_on_boot postgres --state absent
fi
;;
*)
echo "Unknown state: $state" >&2
exit 1
esac

View file

@ -1 +0,0 @@
https://download.nextcloud.com/server/releases/

View file

@ -1 +0,0 @@
11.0.2

View file