diff options
author | Brendan Abolivier | 2016-03-13 21:37:46 +0100 |
---|---|---|
committer | Brendan Abolivier | 2016-03-13 21:37:46 +0100 |
commit | bf94928ab2e0fb955e3ca0bb8ec88c8aaed372bf (patch) | |
tree | 68ef0eaad89d2f08ddf6ef28bc944073aaada6a5 | |
download | aur-bf94928ab2e0fb955e3ca0bb8ec88c8aaed372bf.tar.gz |
First commit
-rw-r--r-- | .SRCINFO | 40 | ||||
-rw-r--r-- | PKGBUILD | 42 | ||||
-rwxr-xr-x | configure-cozy-domain | 26 | ||||
-rw-r--r-- | cozy-standalone.install | 191 |
4 files changed, 299 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d354bafeb231 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,40 @@ +# Generated by mksrcinfo v8 +# Sun Mar 13 20:34:20 UTC 2016 +pkgbase = cozy-standalone + pkgdesc = A personal cloud you can hack, host and delete, packaged without any reverse proxy solution. + pkgver = 2.0 + pkgrel = 1 + url = https://cozy.io/ + install = cozy-standalone.install + arch = any + license = GPL3 + depends = ca-certificates + depends = couchdb + depends = supervisor + depends = bash + depends = curl + depends = git + depends = imagemagick + depends = openssl + depends = libxml2 + depends = libxslt + depends = python2 + depends = python2-setuptools + depends = python2-virtualenv + depends = sqlite + depends = nodejs-lts-bin + depends = pwgen + depends = pngcrush + depends = lsof + depends = cozy-management + optdepends = libjpeg-turbo: Needed for the Kresus app + optdepends = libyaml: Needed for the Kresus app + provides = cozy + conflicts = cozy + source = https://raw.githubusercontent.com/cozy/cozy-debian/master/supervisor-cozy-controller + source = configure-cozy-domain + md5sums = SKIP + md5sums = 603ae0e25b7bf756b3bdc5da20efeec5 + +pkgname = cozy-standalone + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..8f264c68bb82 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,42 @@ +# Maintainer: Brendan Abolivier <brendan@cozycloud.cc> +pkgname=cozy-standalone +pkgver=2.0 +pkgrel=1 +epoch= +pkgdesc="A personal cloud you can hack, host and delete, packaged without any reverse proxy solution." +arch=('any') +url="https://cozy.io/" +license=('GPL3') +groups=() +depends=('ca-certificates' 'couchdb' 'supervisor' 'bash' 'curl' 'git' 'imagemagick' + 'openssl' 'libxml2' 'libxslt' 'python2' 'python2-setuptools' 'python2-virtualenv' 'sqlite' + 'nodejs-lts-bin' 'pwgen' 'pngcrush' 'lsof' 'cozy-management') +makedepends=() +checkdepends=() +optdepends=('libjpeg-turbo: Needed for the Kresus app' + 'libyaml: Needed for the Kresus app') +provides=("cozy") +conflicts=("cozy") +replaces=() +backup=() +options=() +install=$pkgname.install +changelog= +source=("https://raw.githubusercontent.com/cozy/cozy-debian/master/supervisor-cozy-controller" + "configure-cozy-domain") +noextract=() +md5sums=("SKIP" + "603ae0e25b7bf756b3bdc5da20efeec5") + +build() { + echo "Hello world" > /dev/null +} + +package() { + mkdir -p $pkgdir/usr/share/cozy + mkdir -p $pkgdir/etc/cozy + + cp supervisor-cozy-controller $pkgdir/usr/share/cozy + mkdir -p $pkgdir/usr/bin + cp configure-cozy-domain $pkgdir/usr/bin +} diff --git a/configure-cozy-domain b/configure-cozy-domain new file mode 100755 index 000000000000..5a7d18bf4f2b --- /dev/null +++ b/configure-cozy-domain @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ $# -eq 1 ]; then + COZY_DOMAIN=$1 + + CURRENT_DOMAIN=`/usr/bin/cozy_management get_cozy_param domain` + if [ "$CURRENT_DOMAIN" = "$COZY_DOMAIN" ]; then + echo "Cozy already configured with domain: $COZY_DOMAIN" + else + echo "Configuring Cozy with domain: $COZY_DOMAIN" + coffee /usr/local/cozy/apps/home/commands.coffee setdomain $COZY_DOMAIN + fi + + echo 'Generating SSL keys and certificates...' + if [ ! -f /etc/cozy/dh.pem ]; then + openssl dhparam -out /etc/cozy/dh.pem -outform PEM -2 2048 + chmod 400 /etc/cozy/dh.pem + fi + if [ ! -f /etc/cozy/server.crt ]; then + cozy_management normalize_cert_dir + cozy_management generate_certificate ${COZY_DOMAIN} + fi +else + echo "Usage: /usr/bin/configure-cozy-domain cozy.example.tld" + echo "Replace \"cozy.example.tld\" by your Cozy's own domain" +fi diff --git a/cozy-standalone.install b/cozy-standalone.install new file mode 100644 index 000000000000..a56ef00f6aeb --- /dev/null +++ b/cozy-standalone.install @@ -0,0 +1,191 @@ +#!/bin/sh +# Install scripts for Cozy +# Maintainer: Brendan Abolivier <brendan@cozycloud.cc> + +# Fancy message is fancy +msg() { + printf "${blue}==>${bold} $1${all_off}\n" +} + +all_off="$(tput sgr0)" +bold="${all_off}$(tput bold)" +blue="${bold}$(tput setaf 4)" + +post_install() { + msg "Checking ports availability" + lsof -i :9002 > /dev/null 2>&1 + if [ $? = "0" ]; then + msg "Port 9002 (used by the Cozy controller) is already in use on this machine." + exit 1 + fi + lsof -i :9101 > /dev/null 2>&1 + if [ $? = "0" ]; then + msg "Port 9101 (used by the Cozy Data System) is already in use on this machine." + exit 1 + fi + lsof -i :9103 > /dev/null 2>&1 + if [ $? = "0" ]; then + msg "Port 9103 (used by the Cozy Home) is already in use on this machine." + exit 1 + fi + lsof -i :9104 > /dev/null 2>&1 + if [ $? = "0" ]; then + msg "Port 9104 (used by the Cozy authentication proxy) is already in use on this machine." + exit 1 + fi + + msg "Installing CoffeeScript" + npm install -g coffee-script + + msg 'Installing NPM dependencies...' + npm config set python /usr/bin/python2 + [ ! -d /usr/local/lib/node_modules/cozy-controller ] && npm install -g cozy-controller + [ ! -d /usr/local/lib/node_modules/cozy-monitor ] && npm install -g cozy-monitor + + msg 'Creating UNIX users...' + id cozy >/dev/null 2>&1 || useradd -M cozy + id cozy-data-system >/dev/null 2>&1 || useradd -M cozy-data-system + id cozy-home >/dev/null 2>&1 || useradd -M cozy-home + + chown -hR cozy /etc/cozy + + if [ ! -f /etc/cozy/couchdb.login ]; then + msg 'Generating CouchDB tokens...' + pwgen -1 > /etc/cozy/couchdb.login && \ + pwgen -1 >> /etc/cozy/couchdb.login + msg 'Enabling CouchDB' + systemctl enable couchdb + systemctl restart couchdb + COUNT=0;MAX=20 + while ! curl -s 127.0.0.1:5984 >/dev/null; do + let "COUNT += 1" + msg "Waiting for CouchDB to start... ($COUNT/$MAX)" + if [[ $COUNT -ge $MAX ]]; then + msg "CouchDB is too long to start" + exit 1 + fi + sleep 5 + done + curl -s -X PUT 127.0.0.1:5984/_config/admins/$(head -n1 /etc/cozy/couchdb.login) -d "\"$(tail -n1 /etc/cozy/couchdb.login)\"" + fi + chown cozy-data-system /etc/cozy/couchdb.login + chmod 640 /etc/cozy/couchdb.login + + msg 'Configuring Cozy Controller...' + CONFIGFILE=/etc/supervisor.d/cozy-controller.ini + if [ -f $CONFIGFILE ]; then + echo "Old configuration moved to /etc/supervisor.d/cozy-controller.ini.old" + mv /etc/supervisor.d/cozy-controller.ini /etc/supervisor.d/cozy-controller.ini.old + fi + mv /usr/share/cozy/supervisor-cozy-controller /etc/supervisor.d/cozy-controller.ini + + msg 'Starting supervisor' + systemctl enable supervisord + systemctl restart supervisord + + COUNT=0;MAX=20 + while ! curl -s 127.0.0.1:9002 >/dev/null; do + let "COUNT += 1" + msg "Waiting for Cozy Controller to start... ($COUNT/$MAX)" + if [[ $COUNT -ge $MAX ]]; then + msg "Cozy Controller is too long to start" + exit 1 + fi + sleep 5 + done + + msg 'Installing Cozy Platform apps...' + if [ ! -d /usr/local/cozy/apps/data-system ]; then + cozy-monitor install-cozy-stack + if [ $? = "1" ]; then echo "Error while installing the platform" && exit 1; fi + fi + cozy-monitor start data-system + if [ ! -d /usr/local/cozy/apps/home ]; then + cozy-monitor install home + if [ $? = "1" ]; then echo "Error while installing the platform" && exit 1; fi + fi + cozy-monitor start home + if [ ! -d /usr/local/cozy/apps/proxy ]; then + cozy-monitor install proxy + if [ $? = "1" ]; then echo "Error while installing the platform" && exit 1; fi + fi + cozy-monitor start proxy + + + CURRENT_BACKGROUND=`/usr/bin/cozy_management get_cozy_param background` + if [ "$CURRENT_BACKGROUND" != "None" ]; then + echo "Cozy already configured with a background: $CURRENT_BACKGROUND" + else + echo "Configure Cozy with default background" + curl -X POST http://localhost:9103/api/instance -H "Content-Type: application/json" -d '{"background":"background-07"}' + fi + + # Correcting display here + echo "" + msg "Installing default apps" + for app in calendar contacts photos emails files sync; do + if [ ! -f /usr/local/cozy/apps/.first-install-$app ]; then + if [ -d /usr/local/cozy/apps/$app ]; then + touch /usr/local/cozy/apps/.first-install-$app + else + cozy-monitor install $app && touch /usr/local/cozy/apps/.first-install-$app + fi + fi + done + + if [ ! -f /usr/local/cozy/apps/.first-install-import-from-google ]; then + if [ -d /usr/local/cozy/apps/import-from-google ]; then + touch /usr/local/cozy/apps/.first-install-import-from-google + else + cozy-monitor install import-from-google -r https://github.com/cozy-labs/import-from-google.git && touch /usr/local/cozy/apps/.first-install-import-from-google + fi + fi + + + msg "This package does not come with any configuration for reverse proxying, which is crucial for Cozy's well behaviour. In order for the platform to work, please configure a reverse proxy.\nFor more information, please visit https://docs.cozy.io/en/host/install/install-on-archlinux.html" + echo "Before being able to use Cozy, you need to run the first-time-configuration script:" + echo " # /usr/bin/configure-cozy-domain cozy.example.tld" + echo "With your Cozy's own domain instead of \"cozy.example.tld\"" +} + +pre_remove() { + which cozy-monitor >/dev/null 2>&1 + RESULT=$? + if [ "$RESULT" = "0" ]; then + APPS="$(cozy-monitor status | grep -vE '(mta|postfix|couch|controller|data-system|ds|home|proxy|error)' | sed 's/:.*//;s/\[Error//' | xargs echo)" + APPS="$APPS proxy home data-system" + for app in $APPS ; do cozy-monitor uninstall $app ; done + fi + which supervisorctl >/dev/null 2>&1 && supervisorctl stop cozy-controller +} + +post_remove() { + mv /etc/cozy/couchdb.login /tmp/couchdb.login + [ -d /etc/cozy ] && msg "Deleting /etc/cozy directory" && rm -rf /etc/cozy + [ -d /usr/local/var/log/cozy ] && msg "Deleting /usr/local/var/log/cozy directory" && rm -rf /usr/local/var/log/cozy + [ -d /usr/local/cozy ] && msg "Deleting /usr/local/cozy directory" && rm -rf /usr/local/cozy + msg "Erasing scripts and folders" + [ -f /usr/local/sbin/debian-reconfigure-cozy-domain.sh ] && rm -f /usr/local/sbin/debian-reconfigure-cozy-domain.sh + [ -d /usr/local/var/cozy ] && rm -rf /usr/local/var/cozy + [ -d /usr/share/cozy ] && rm -rf /usr/share/cozy + msg "Removing NPM dependencies" + [ -f /usr/bin/cozy-controller ] && npm remove -g cozy-controller + [ -f /usr/bin/cozy-controller ] && npm remove -g cozy-monitor + msg "Removing supervisor configuration" + test -e /etc/supervisor.d/cozy* && rm /etc/supervisor.d/cozy* + supervisorctl reload + echo "The Cozy database contains all your user data. Keeping it could be troublesome for further installations. However, it will not be removed, unless you do it manually." + echo "Moved the admin logins to /tmp/couchdb.login" + echo "Please don't forget to move it elsewhere if you don't want to lose access to your whole database." +} + +post_upgrade() { + # Check if the install went well + cozy-monitor status > /dev/null 2>&1 + if [ $? = "1" ]; then + post_install + else + # Do update here + echo "Hello world" > /dev/null + fi +} |