This commit is contained in:
Modulos 2017-04-21 06:57:03 +02:00
commit fdbcb08c4f
8 changed files with 187 additions and 0 deletions

0
explorer/state Normal file
View file

1
files/nextcloud.nginx Normal file
View file

@ -0,0 +1 @@

38
files/nextcloud.sh Normal file
View file

@ -0,0 +1,38 @@
#!/bin/bash
ocpath='/var/www/nextcloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'
printf "Creating possible missing Directories\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater
printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
chmod 755 ${ocpath}
printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi

59
gencode-remote Executable file
View file

@ -0,0 +1,59 @@
#!/bin/sh
os=$(cat "$__global/explorer/os")
if [ ! "$os" = "debian" ]
then
echo "OS $os is currently not supported." >&2
exit 1
fi
os_version=$(cat "$__global/explorer/os_version")
case "$os_version" in
8*)
:
;;
*)
echo "Unsupported version $os_version of $os." >&2
exit 1
;;
esac
nextcloud_dir="/$__object_id"
if [ ! "$nextcloud_dir" ]
then
echo "Missing nextcloud directory (object_id)." >&2
exit 1
fi
state=$(cat "$__object/parameter/state")
exists=$(cat "$__object/explorer/exists")
case "$state" in
present)
[ "$exists" = "yes" ] && exit 0
nextcloud_url=$(cat "$__object/parameter/nextcloud-uri")
if [ ! "${nextcloud_url}" ]
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
tar -C /var/www -xvjf ${nextcloud_dir}/nextcloud.tar.bz2
rm ${nextcloud_dir}/nextcloud.tar.bz2
bash ${__object}/files/nextcloud.sh
eof
;;
absent)
# all done in manifest
:
;;
*)
echo "Unknown state: $state" >&2
exit 1
esac

87
manifest Normal file
View file

@ -0,0 +1,87 @@
#!/bin/sh
os=$(cat "$__global/explorer/os")
if [ ! "$os" = "debian" ]
then
echo "OS $os is currently not supported." >&2
exit 1
fi
os_version=$(cat "$__global/explorer/os_version")
case "$os_version" in
8*)
:
;;
*)
echo "Unsupported version $os_version of $os." >&2
exit 1
;;
esac
nextcloud_dir="/$__object_id"
if [ ! "$nextcloud_dir" ]
then
echo "Missing nextcloud directory (object_id)." >&2
exit 1
fi
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
# Setup LAMP
__package apach2 --state=present
# Get server name or ip from parameters
server_name=$(cat "$__object/parameter/server-name")
__file /etc/systemd/system/nextcloud.service --owner root \
--group root \
--mode 755 --source - << EOF
ServerName ${server_name}
EOF
# Config Firewall
# Setup mysql
__package mysql-server --state=present
mysql_password=$(cat "$__object/parameter/mysql-password")
__mysql_database "nextcloud" --name "nextcloud" --user "nextcloud" \
--password "${mysql_password}"
# Install PHP
for package in php libapache2-mod-php php-mcrypt php-mysql
do __package $package --state=present
done
# Install additional php packages
for package in php-bz2 php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip
do __package $package --state=present
done
require="__package/apache2" __file /etc/apache2/sites-available/nextcloud.conf
--owner root \
--group root \
--mode 755 --source "$__type/files/nextcloud.apache" \
--state exists
# Enable nextcloud site
__process a2ensite nextcloud
# Enable mod_rewrite (required by nextcloud)
__process a2enmod rewrite
absent)
# TODO:
if [ "$exists" ]
then
fi
;;
*)
echo "Unknown state: $state" >&2
exit 1
esac

View file

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

View file

@ -0,0 +1 @@
11.0.2

0
parameter/state Normal file
View file