From 03e1eb65d227d0d800cc3681f4fc5338aa0696a0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 10 Feb 2017 17:06:59 +0100 Subject: [PATCH] Initial commit --- LICENSE | 1 + README.md | 4 ++ conf/nginx.conf | 13 +++++ manifest.json | 75 ++++++++++++++++++++++++++++ scripts/install | 126 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/remove | 19 +++++++ sources/.gitkeep | 0 7 files changed, 238 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 conf/nginx.conf create mode 100644 manifest.json create mode 100755 scripts/install create mode 100755 scripts/remove create mode 100644 sources/.gitkeep diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac17d84 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +File containning the license of your package. diff --git a/README.md b/README.md new file mode 100644 index 0000000..491b1eb --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Wekan for Yunohost + +Attempt to package Wekan for Yunohost.... + diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..4059690 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,13 @@ +location YNH_WWW_PATH { + + # Path to source + alias YNH_WWW_ALIAS ; + + # Example PHP configuration (remove if not used) + index index.php; + + try_files $uri $uri/ index.php; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f0fbbba --- /dev/null +++ b/manifest.json @@ -0,0 +1,75 @@ +{ + "name": "Wekan", + "id": "wekan", + "packaging_format": 1, + "description": { + "en": "Trello-like kanban", + "fr": "Un kanban similaire à Trello" + }, + "url": "https://wekan.io", + "license": "free", + "maintainer": { + "name": "alexAubin", + "email": "alex.aubin@mailoo.org", + "url": "https://github.com/alexAubin/" + }, + "requirements": { + "yunohost": ">> 2.4.0" + }, + "multi_instance": false, + "services": [ + "nginx", + "php5-fpm", + "mysql" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain name for Wekan", + "fr": "Choisissez un nom de domaine pour Wekan" + }, + "example": "example.com" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Wekan", + "fr": "Choisissez un chemin pour Wekan" + }, + "example": "/wekan", + "default": "/wekan" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose an admin user", + "fr": "Choisissez l’administrateur" + }, + "example": "johndoe" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" + }, + "default": true + }, + { + "name": "language", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["fr", "en"], + "default": "fr" + } + ] + } +} diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..abf8f32 --- /dev/null +++ b/scripts/install @@ -0,0 +1,126 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# Arguments from manifest +app=$YNH_APP_INSTANCE_NAME +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE + +src_path="/var/www/wekan" + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Save app settings +ynh_app_setting_set "$app" admin "$admin" +ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" language "$language" + +# Check domain/path availability +sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ + || ynh_die "Path not available: ${domain}${path_url}" + + + +INSTALL_USER=admin + +# Install nvm +export NVM_DIR="/opt/nvm" +sudo curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | sudo NVM_DIR=$NVM_DIR bash + +# Install latest nodejs +sudo su -c ". $NVM_DIR/nvm.sh && nvm install 0.10 && nvm use 0.10" + +# Install npm +sudo apt-get update +sudo apt-get -y install npm + +# Add some swap :/ +if [ $(free | tail -n 1 | awk '{print $2}') -lt 1000000 ]; +then + if [[ -z $(mount | grep /tmp | grep tmpfs) ]]; + then + tmp_swap_file=/tmp/wekan_swapfile + else + # It is NOT possible to setup a swap file on a tmpfs filesystem + tmp_swap_file=/var/cache/wekan_swapfile + fi + sudo dd if=/dev/zero of=$tmp_swap_file bs=1M count=1024 + sudo chmod 600 $tmp_swap_file + sudo mkswap $tmp_swap_file + sudo swapon $tmp_swap_file +fi + +# Install meteor +METEOR_INSTALL_DIR="/opt/meteor" +METEOR_BIN="/usr/local/bin/meteor" +#sudo rm -rf $METEOR_INSTALL_DIR +#sudo cp -r ../sources/meteor $METEOR_INSTALL_DIR +#sudo git clone --recursive https://github.com/meteor/meteor.git $METEOR_INSTALL_DIR -b release-1.3.5 +#NODE_BIN=`sudo su -c ". $NVM_DIR/nvm.sh && nvm use 0.10 >/dev/null && which node"` +#sudo mkdir -p /opt/meteor/dev_bundle/bin/ +#sudo ln -s $NODE_BIN /opt/meteor/dev_bundle/bin/node + +sudo su admin -c ". $NVM_DIR/nvm.sh && nvm use 0.10 && curl https://install.meteor.com/ | sh" + +#sudo chown -R admin $METEOR_INSTALL_DIR +#cd $METEOR_INSTALL_DIR +#./meteor --help +#sudo rm -f $METEOR_BIN +#sudo ln -s $METEOR_INSTALL_DIR/meteor $METEOR_BIN + + +# Install wekan +sudo mkdir -p $src_path +cd $src_path +sudo git clone https://github.com/wekan/wekan.git . +sudo chown -R admin /var/www/wekan/ +sudo su -c ". $NVM_DIR/nvm.sh && nvm use 0.10 && npm install" +sudo rm -rf .build +sudo su admin -c ". $NVM_DIR/nvm.sh && nvm use 0.10 && $METEOR_BIN build .build --directory" +cd .build/bundle/programs/server +sudo su -c ". $NVM_DIR/nvm.sh && nvm use 0.10 && npm install" +#sudo su admin -c ". $NVM_DIR/nvm.sh && nvm use 0.10 && meteor build .build --directory" + +# Disable swapfile +if [[ -v "$tmp_swap_file" ]]; +then + sudo swapoff $tmp_swap_file + sudo rm -f $tmp_swap_file +fi + +# Configure stuff ? +export MONGO_URL="mongodb://127.0.0.1:27017/wekan" +export ROOT_URL="https://${domain}" +export MAIL_URL="smtp://root@localhost/" +export PORT=8081 + +# Launch ? +cd ../../ +node main.js + + + + + + + +# Modify Nginx configuration file and copy it to Nginx conf directory +nginx_conf=../conf/nginx.conf +sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf +sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf +sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf + +# If app is public, add url to SSOWat conf as skipped_uris +if [[ $is_public -eq 1 ]]; then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set "$app" unprotected_uris "/" +fi + +# Reload services +sudo service nginx reload diff --git a/scripts/remove b/scripts/remove new file mode 100755 index 0000000..9a5dc51 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,19 @@ +#!/bin/bash + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Retrieve app settings +domain=$(ynh_app_setting_get "$app" domain) + +# Remove sources +sudo rm -rf /var/www/$app + +# Remove nginx configuration file +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +# Reload nginx service +sudo service nginx reload diff --git a/sources/.gitkeep b/sources/.gitkeep new file mode 100644 index 0000000..e69de29