mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
Merge 2dfe1f3809
into b9346e4508
This commit is contained in:
commit
7030930ec4
1 changed files with 314 additions and 195 deletions
509
ynh-dev
509
ynh-dev
|
@ -1,51 +1,148 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
usage() {
|
###############################################################################
|
||||||
cat <<EOF
|
# Global variables #
|
||||||
Usage :
|
###############################################################################
|
||||||
|
|
||||||
On the host
|
readonly IP_BASE="192.168.33."
|
||||||
`basename $0` create-env PATH
|
readonly SCRIPT_NAME=`basename $0`
|
||||||
Create a dev environment into PATH
|
readonly KNOWN_PACKAGES="moulinette ssowat yunohost yunohost-admin"
|
||||||
`basename $0` run DOMAIN [VERSION]
|
readonly KNOWN_VERSIONS="stable testing unstable"
|
||||||
Run a vagrant or virtualbox vm
|
readonly BASE_INSIDE_VM="/vagrant"
|
||||||
# `basename $0` kill
|
|
||||||
# Kill all vagrant
|
|
||||||
|
|
||||||
Inside the vm
|
###############################################################################
|
||||||
`basename $0` ip
|
# Usage and options parsing #
|
||||||
Give the ip of the guest container
|
###############################################################################
|
||||||
`basename $0` upgrade
|
|
||||||
Upgrade the container
|
|
||||||
`basename $0` use-git [PACKAGES [PACKAGES ...]]
|
|
||||||
Use Git repositories from dev environment path
|
|
||||||
`basename $0` test [PACKAGES [PACKAGES ...]]
|
|
||||||
Deploy, update and run tests for some packages
|
|
||||||
`basename $0` self-update
|
|
||||||
Update this script (`basename $0`)
|
|
||||||
|
|
||||||
PACKAGES :
|
show_usage()
|
||||||
moulinette
|
{
|
||||||
ssowat
|
cat <<- EOF
|
||||||
yunohost
|
Usage :
|
||||||
yunohost-admin
|
|
||||||
|
|
||||||
VERSION
|
On the host
|
||||||
stable
|
-----------
|
||||||
testing
|
|
||||||
unstable
|
create-env PATH
|
||||||
EOF
|
Create a dev environment into PATH
|
||||||
|
run DOMAIN [VERSION]
|
||||||
|
Run a vagrant or virtualbox vm
|
||||||
|
kill
|
||||||
|
Kill all vagrant
|
||||||
|
|
||||||
|
Inside the vm
|
||||||
|
-------------
|
||||||
|
|
||||||
|
ip
|
||||||
|
Give the ip of the guest container
|
||||||
|
upgrade
|
||||||
|
Upgrade the container
|
||||||
|
use-git [PACKAGE [PACKAGE ...]]
|
||||||
|
Use Git repositories from dev environment path
|
||||||
|
test [PACKAGE [PACKAGE ...]]
|
||||||
|
Deploy, update and run tests for some packages
|
||||||
|
self-update
|
||||||
|
Update this script (${SCRIPT_NAME})
|
||||||
|
|
||||||
|
# PACKAGES
|
||||||
|
|
||||||
|
moulinette
|
||||||
|
ssowat
|
||||||
|
yunohost
|
||||||
|
yunohost-admin
|
||||||
|
|
||||||
|
# VERSIONS
|
||||||
|
|
||||||
|
stable
|
||||||
|
testing
|
||||||
|
unstable
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
check_yunohost_vm() {
|
execute_action()
|
||||||
if [ ! -d /etc/yunohost ]
|
{
|
||||||
then
|
local ACTION="$1"
|
||||||
echo "You need to install YunoHost first. Maybe you are not in a vm ?"
|
local ARGUMENTS="${@:2}"
|
||||||
exit 100;
|
|
||||||
fi
|
case "${ACTION}" in
|
||||||
|
help|-h|--help) show_usage $ARGUMENTS ;;
|
||||||
|
create-env|--create-env) create_env $ARGUMENTS ;;
|
||||||
|
run|--run) run_vm $ARGUMENTS ;;
|
||||||
|
kill|--kill) kill_vm $ARGUMENTS ;;
|
||||||
|
ip|--ip) show_vm_ip $ARGUMENTS ;;
|
||||||
|
upgrade|--upgrade) upgrade_vm $ARGUMENTS ;;
|
||||||
|
use-git|--use-git) use_git $ARGUMENTS ;;
|
||||||
|
test|--test) run_tests $ARGUMENTS ;;
|
||||||
|
self-update|--self-update) self_update $ARGUMENTS ;;
|
||||||
|
*)
|
||||||
|
echo "Unknown action ${ACTION}."
|
||||||
|
show_usage
|
||||||
|
exit 100
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
create_sym_link() {
|
###############################################################################
|
||||||
|
# Helpers #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
is_empty_string()
|
||||||
|
{
|
||||||
|
[[ -z "$1" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_not_empty_string()
|
||||||
|
{
|
||||||
|
[[ -n "$1" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
file_exists()
|
||||||
|
{
|
||||||
|
[[ -e "$1" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_directory()
|
||||||
|
{
|
||||||
|
[[ -d "$1" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
list_contains_element () {
|
||||||
|
local LIST="$1"
|
||||||
|
local ELEMENT_TO_FIND="$2"
|
||||||
|
local ELEMENT
|
||||||
|
for ELEMENT in ${LIST}; do
|
||||||
|
[[ "$ELEMENT" == "$ELEMENT_TO_FIND" ]] && return 0;
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_inside_yunohost_vm()
|
||||||
|
{
|
||||||
|
is_directory "/etc/yunohost" || {
|
||||||
|
echo "You are not inside a Yunohost instance. Maybe you need to install it first ?"
|
||||||
|
exit 101;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_package_is_known()
|
||||||
|
{
|
||||||
|
local PACKAGE="$1"
|
||||||
|
list_contains_element "$KNOWN_PACKAGES" "$PACKAGE" || {
|
||||||
|
echo "ERROR: Incorrect package '$PACKAGE'. See '${SCRIPT_NAME} --help' for usage."
|
||||||
|
exit 102
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_version_is_known()
|
||||||
|
{
|
||||||
|
local VERSION="$1"
|
||||||
|
list_contains_element "$KNOWN_VERSIONS" "$VERSION" || {
|
||||||
|
echo "ERROR: Incorrect version '$VERSION'. See '${SCRIPT_NAME} --help' for usage."
|
||||||
|
exit 103
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
create_sym_link()
|
||||||
|
{
|
||||||
# Remove current sources if not a symlink
|
# Remove current sources if not a symlink
|
||||||
if [ ! -L '$2' ]; then
|
if [ ! -L '$2' ]; then
|
||||||
sudo rm -rf $2
|
sudo rm -rf $2
|
||||||
|
@ -54,37 +151,27 @@ create_sym_link() {
|
||||||
sudo ln -sfn $1 $2
|
sudo ln -sfn $1 $2
|
||||||
}
|
}
|
||||||
|
|
||||||
packages=${@:2}
|
|
||||||
if [ "$#" = "1" ]; then
|
|
||||||
packages=('moulinette' 'ssowat' 'yunohost' 'yunohost-admin')
|
|
||||||
fi
|
|
||||||
|
|
||||||
BASE_DIR=./
|
|
||||||
IP_BASE="192.168.33."
|
|
||||||
|
|
||||||
##################
|
|
||||||
## Help message ##
|
|
||||||
##################
|
|
||||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ]; then
|
|
||||||
usage
|
|
||||||
|
|
||||||
|
|
||||||
######################################
|
###############################################################################
|
||||||
## Create a development environment ##
|
# Create a development environment #
|
||||||
######################################
|
###############################################################################
|
||||||
elif [ "$1" = "create-env" ]; then
|
|
||||||
|
create_env()
|
||||||
|
{
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
pwd=`pwd`
|
local PATH_="$1"
|
||||||
|
|
||||||
if [ ! "$2" ]
|
is_not_empty_string "$PATH_" \
|
||||||
then
|
|| { echo "I need a destination folder to create the dev environnement"
|
||||||
echo "I need a destination folder to create the dev environement"
|
exit 104
|
||||||
exit 1
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
[ -e "$2" ] || mkdir -p $2
|
file_exists "$PATH_" \
|
||||||
cd $2
|
|| mkdir -p "$PATH_"
|
||||||
|
|
||||||
|
cd "$PATH_"
|
||||||
|
|
||||||
# Create apps & backup folder
|
# Create apps & backup folder
|
||||||
mkdir -p apps
|
mkdir -p apps
|
||||||
|
@ -103,48 +190,38 @@ elif [ "$1" = "create-env" ]; then
|
||||||
# Get YunoHost dev tools
|
# Get YunoHost dev tools
|
||||||
git clone -b master https://github.com/YunoHost/ynh-dev ynh-dev-tools
|
git clone -b master https://github.com/YunoHost/ynh-dev ynh-dev-tools
|
||||||
cp ynh-dev-tools/ynh-dev ynh-dev
|
cp ynh-dev-tools/ynh-dev ynh-dev
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Run a vm and give a prompt #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
#################################
|
run_vm()
|
||||||
## Run a vm and give a prompt ##
|
{
|
||||||
#################################
|
local DOMAIN="$1"
|
||||||
elif [ "$1" = "run" ]; then
|
local VERSION="${2:-stable}" # (use $2, or "stable" by default)
|
||||||
|
|
||||||
DOMAIN=$2
|
# Get vagrant box info from version
|
||||||
VERSION='stable'
|
local VMNAME="${DOMAIN//./_}"
|
||||||
if [ "$#" = "3" ]; then
|
local BOX_NAME="yunohost/jessie-${VERSION}"
|
||||||
VERSION=$3
|
local BOX_URL="https://build.yunohost.org/yunohost-jessie-${VERSION}.box"
|
||||||
fi
|
|
||||||
|
assert_version_is_known "$VERSION"
|
||||||
|
|
||||||
echo "Creating $DOMAIN virtual machine with YunoHost $VERSION version"
|
echo "Creating $DOMAIN virtual machine with YunoHost $VERSION version"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Get vagrant box info from version
|
|
||||||
if [ "$VERSION" = "stable" ]; then
|
|
||||||
BOX_NAME="yunohost/jessie-stable"
|
|
||||||
BOX_URL="https://build.yunohost.org/yunohost-jessie-stable.box"
|
|
||||||
elif [ "$VERSION" = "testing" ]; then
|
|
||||||
BOX_NAME="yunohost/jessie-testing"
|
|
||||||
BOX_URL="https://build.yunohost.org/yunohost-jessie-testing.box"
|
|
||||||
elif [ "$VERSION" = "unstable" ]; then
|
|
||||||
BOX_NAME="yunohost/jessie-unstable"
|
|
||||||
BOX_URL="https://build.yunohost.org/yunohost-jessie-unstable.box"
|
|
||||||
else
|
|
||||||
echo "ERROR: Incorrect version '$VERSION'. See '$(basename $0) --help' for usage."
|
|
||||||
exit 102
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Download box if not available
|
# Download box if not available
|
||||||
if ! vagrant box list | grep -qc $BOX_NAME ; then
|
if ! vagrant box list | grep -qc $BOX_NAME ; then
|
||||||
echo "Vagrant box '$BOX_NAME' is missing. Trying to download it"
|
echo "Vagrant box '$BOX_NAME' is missing. Trying to download it"
|
||||||
vagrant box add $BOX_NAME $BOX_URL --provider virtualbox
|
vagrant box add $BOX_NAME $BOX_URL --provider virtualbox
|
||||||
|
#[ $? -eq 0 ] || {
|
||||||
|
# echo "Download failed of $BOX_NAME from $BOX_URL failed !"
|
||||||
|
# exit 105
|
||||||
|
#}
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deduce the vm name
|
|
||||||
VMNAME=${DOMAIN//./_}
|
|
||||||
|
|
||||||
|
|
||||||
# Add the vm vagrant config in Vagrantfile
|
# Add the vm vagrant config in Vagrantfile
|
||||||
vagrant status $VMNAME &> /dev/null || {
|
vagrant status $VMNAME &> /dev/null || {
|
||||||
|
|
||||||
|
@ -152,14 +229,14 @@ elif [ "$1" = "run" ]; then
|
||||||
for i in `seq 1 254`;
|
for i in `seq 1 254`;
|
||||||
do
|
do
|
||||||
grep "${IP_BASE//./\.}$i" Vagrantfile &> /dev/null || {
|
grep "${IP_BASE//./\.}$i" Vagrantfile &> /dev/null || {
|
||||||
IP="${IP_BASE}$i"
|
local IP="${IP_BASE}$i"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
sed -i "/ ### END AUTOMATIC YNH-DEV ###/ i \\
|
sed -i "/ ### END AUTOMATIC YNH-DEV ###/ i \\
|
||||||
config.vm.define \"${VMNAME}\" do |${VMNAME}| \
|
config.vm.define \"${VMNAME}\" do |${VMNAME}| \
|
||||||
\n ${VMNAME}.vm.box = \"yunohost/jessie-${VERSION}\" \
|
\n ${VMNAME}.vm.box = \"${BOX_NAME}\" \
|
||||||
\n ${VMNAME}.vm.network :private_network, ip: \"${IP}\" \
|
\n ${VMNAME}.vm.network :private_network, ip: \"${IP}\" \
|
||||||
\n end \
|
\n end \
|
||||||
\n" ./Vagrantfile
|
\n" ./Vagrantfile
|
||||||
|
@ -169,8 +246,8 @@ elif [ "$1" = "run" ]; then
|
||||||
vagrant up $VERSION --provider virtualbox
|
vagrant up $VERSION --provider virtualbox
|
||||||
|
|
||||||
# Warn user about hosts file
|
# Warn user about hosts file
|
||||||
IP_LINE="\s\s*${VMNAME}.vm.network\s\s*:private_network,\s*ip:\s*\""
|
local IP_LINE="\s\s*${VMNAME}.vm.network\s\s*:private_network,\s*ip:\s*\""
|
||||||
IP=$(grep "$IP_LINE" Vagrantfile | sed "s/${IP_LINE}//")
|
local IP=$(grep "$IP_LINE" Vagrantfile | sed "s/${IP_LINE}//")
|
||||||
IP=${IP::-1}
|
IP=${IP::-1}
|
||||||
echo "/!\ Please add '$IP $DOMAIN' to your /etc/hosts file /!\\"
|
echo "/!\ Please add '$IP $DOMAIN' to your /etc/hosts file /!\\"
|
||||||
echo "sudo sh -s 'echo \"$IP $DOMAIN\" >> /etc/hosts'"
|
echo "sudo sh -s 'echo \"$IP $DOMAIN\" >> /etc/hosts'"
|
||||||
|
@ -179,91 +256,107 @@ elif [ "$1" = "run" ]; then
|
||||||
# Log into the VM
|
# Log into the VM
|
||||||
vagrant ssh $VERSION
|
vagrant ssh $VERSION
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#####################
|
###############################################################################
|
||||||
## Kill running VM ##
|
# Kill running VM #
|
||||||
#####################
|
###############################################################################
|
||||||
elif [ "$1" = "kill" ]; then
|
|
||||||
|
kill_vm()
|
||||||
|
{
|
||||||
vagrant destroy
|
vagrant destroy
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Upgrade current VM #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
#######################
|
upgrade_vm()
|
||||||
## Update current VM ##
|
{
|
||||||
#######################
|
assert_inside_yunohost_vm
|
||||||
elif [ "$1" = "upgrade" ]; then
|
|
||||||
check_yunohost_vm
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y upgrade
|
sudo apt-get -y upgrade
|
||||||
sudo apt-get -y dist-upgrade
|
sudo apt-get -y dist-upgrade
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Get current VM IP #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
#######################
|
show_vm_ip()
|
||||||
## Get current VM IP ##
|
{
|
||||||
#######################
|
assert_inside_yunohost_vm
|
||||||
elif [ "$1" = "ip" ]; then
|
|
||||||
check_yunohost_vm
|
|
||||||
# Print IP
|
# Print IP
|
||||||
ip=$(/bin/ip a | grep 'inet 192.168' | awk -F " " '{print $2}' | awk -F "/" '{print $1}')
|
local ip=$(/bin/ip a | grep 'inet 192.168' | awk -F " " '{print $2}' | awk -F "/" '{print $1}')
|
||||||
echo "IP: $ip"
|
echo "IP: $ip"
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Use Git version for YunoHost packages #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
###########################################
|
use_git()
|
||||||
## Use Git version for YunoHost packages ##
|
{
|
||||||
###########################################
|
assert_inside_yunohost_vm
|
||||||
elif [ "$1" = "use-git" ]; then
|
PACKAGES="$@"
|
||||||
check_yunohost_vm
|
|
||||||
VERSION=$2
|
|
||||||
|
|
||||||
for i in ${!packages[@]}; do
|
is_not_empty_string "$PACKAGES" || PACKAGES=${KNOWN_PACKAGES}
|
||||||
case ${packages[i]} in
|
|
||||||
|
echo $PACKAGES
|
||||||
|
|
||||||
|
local PACKAGE
|
||||||
|
for PACKAGE in $PACKAGES; do
|
||||||
|
echo $PACKAGE
|
||||||
|
assert_package_is_known $PACKAGE
|
||||||
|
case "$PACKAGE" in
|
||||||
ssowat)
|
ssowat)
|
||||||
echo "Using Git repository for SSOwat"
|
echo "Using Git repository for SSOwat"
|
||||||
create_sym_link "/vagrant/ssowat" "/usr/share/ssowat"
|
create_sym_link "${BASE_INSIDE_VM}/ssowat" "/usr/share/ssowat"
|
||||||
echo "↳ Don't forget to do 'sudo yunohost app ssowatconf' when hacking SSOwat"
|
echo "↳ Don't forget to do 'sudo yunohost app ssowatconf' when hacking SSOwat"
|
||||||
echo ""
|
echo ""
|
||||||
;;
|
;;
|
||||||
moulinette)
|
moulinette)
|
||||||
create_sym_link "/vagrant/moulinette/locales" "/usr/share/moulinette/locale"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/locales" "/usr/share/moulinette/locale"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/authenticators" "/usr/lib/python2.7/dist-packages/moulinette/authenticator"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/authenticators" "/usr/lib/python2.7/dist-packages/moulinette/authenticator"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/interfaces" "/usr/lib/python2.7/dist-packages/moulinette/interfaces"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/interfaces" "/usr/lib/python2.7/dist-packages/moulinette/interfaces"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/utils" "/usr/lib/python2.7/dist-packages/moulinette/utils"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/utils" "/usr/lib/python2.7/dist-packages/moulinette/utils"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/__init__.py" "/usr/lib/python2.7/dist-packages/moulinette/__init__.py"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/__init__.py" "/usr/lib/python2.7/dist-packages/moulinette/__init__.py"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/core.py" "/usr/lib/python2.7/dist-packages/moulinette/core.py"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/core.py" "/usr/lib/python2.7/dist-packages/moulinette/core.py"
|
||||||
create_sym_link "/vagrant/moulinette/moulinette/actionsmap.py" "/usr/lib/python2.7/dist-packages/moulinette/actionsmap.py"
|
create_sym_link "${BASE_INSIDE_VM}/moulinette/moulinette/actionsmap.py" "/usr/lib/python2.7/dist-packages/moulinette/actionsmap.py"
|
||||||
echo "↳ If you add files at the root of this directory /vagrant/moulinette/moulinette/ you should adapt ynh-dev"
|
echo "↳ If you add files at the root of this directory ${BASE_INSIDE_VM}/moulinette/moulinette/ you should adapt ynh-dev"
|
||||||
echo ""
|
echo ""
|
||||||
;;
|
;;
|
||||||
yunohost)
|
yunohost)
|
||||||
echo "Using Git repository for yunohost"
|
echo "Using Git repository for yunohost"
|
||||||
|
|
||||||
# bin
|
# bin
|
||||||
create_sym_link "/vagrant/yunohost/bin/yunohost" "/usr/bin/yunohost"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/bin/yunohost" "/usr/bin/yunohost"
|
||||||
create_sym_link "/vagrant/yunohost/bin/yunohost-api" "/usr/bin/yunohost-api"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/bin/yunohost-api" "/usr/bin/yunohost-api"
|
||||||
|
|
||||||
# data
|
# data
|
||||||
create_sym_link "/vagrant/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost"
|
||||||
create_sym_link "/vagrant/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml"
|
||||||
create_sym_link "/vagrant/yunohost/data/hooks" "/usr/share/yunohost/hooks"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/hooks" "/usr/share/yunohost/hooks"
|
||||||
create_sym_link "/vagrant/yunohost/data/templates" "/usr/share/yunohost/templates"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/templates" "/usr/share/yunohost/templates"
|
||||||
create_sym_link "/vagrant/yunohost/data/helpers" "/usr/share/yunohost/helpers"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/helpers" "/usr/share/yunohost/helpers"
|
||||||
create_sym_link "/vagrant/yunohost/data/helpers.d" "/usr/share/yunohost/helpers.d"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/helpers.d" "/usr/share/yunohost/helpers.d"
|
||||||
create_sym_link "/vagrant/yunohost/data/other" "/usr/share/yunohost/yunohost-config/moulinette"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/data/other" "/usr/share/yunohost/yunohost-config/moulinette"
|
||||||
|
|
||||||
# debian
|
# debian
|
||||||
create_sym_link "/vagrant/yunohost/debian/conf/pam/mkhomedir" "/usr/share/pam-configs/mkhomedir"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/debian/conf/pam/mkhomedir" "/usr/share/pam-configs/mkhomedir"
|
||||||
|
|
||||||
# lib
|
# lib
|
||||||
create_sym_link "/vagrant/yunohost/lib/metronome/modules/ldap.lib.lua" "/usr/lib/metronome/modules/ldap.lib.lua"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/lib/metronome/modules/ldap.lib.lua" "/usr/lib/metronome/modules/ldap.lib.lua"
|
||||||
create_sym_link "/vagrant/yunohost/lib/metronome/modules/mod_auth_ldap2.lua" "/usr/lib/metronome/modules/mod_auth_ldap2.lua"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/lib/metronome/modules/mod_auth_ldap2.lua" "/usr/lib/metronome/modules/mod_auth_ldap2.lua"
|
||||||
create_sym_link "/vagrant/yunohost/lib/metronome/modules/mod_legacyauth.lua" "/usr/lib/metronome/modules/mod_legacyauth.lua"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/lib/metronome/modules/mod_legacyauth.lua" "/usr/lib/metronome/modules/mod_legacyauth.lua"
|
||||||
create_sym_link "/vagrant/yunohost/lib/metronome/modules/mod_storage_ldap.lua" "/usr/lib/metronome/modules/mod_storage_ldap.lua"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/lib/metronome/modules/mod_storage_ldap.lua" "/usr/lib/metronome/modules/mod_storage_ldap.lua"
|
||||||
create_sym_link "/vagrant/yunohost/lib/metronome/modules/vcard.lib.lua" "/usr/lib/metronome/modules/vcard.lib.lua"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/lib/metronome/modules/vcard.lib.lua" "/usr/lib/metronome/modules/vcard.lib.lua"
|
||||||
|
|
||||||
# src
|
# src
|
||||||
create_sym_link "/vagrant/yunohost/src/yunohost" "/usr/lib/moulinette/yunohost"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/src/yunohost" "/usr/lib/moulinette/yunohost"
|
||||||
|
|
||||||
# locales
|
# locales
|
||||||
create_sym_link "/vagrant/yunohost/locales" "/usr/lib/moulinette/yunohost/locales"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost/locales" "/usr/lib/moulinette/yunohost/locales"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
;;
|
;;
|
||||||
|
@ -273,7 +366,7 @@ elif [ "$1" = "use-git" ]; then
|
||||||
getent passwd vagrant > /dev/null
|
getent passwd vagrant > /dev/null
|
||||||
if [ $? -eq 2 ]; then
|
if [ $? -eq 2 ]; then
|
||||||
useradd vagrant
|
useradd vagrant
|
||||||
chown -R vagrant: /vagrant/yunohost-admin
|
chown -R vagrant: ${BASE_INSIDE_VM}/yunohost-admin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install npm dependencies if needed
|
# Install npm dependencies if needed
|
||||||
|
@ -282,22 +375,22 @@ elif [ "$1" = "use-git" ]; then
|
||||||
then
|
then
|
||||||
sudo apt-get update --fix-missing
|
sudo apt-get update --fix-missing
|
||||||
sudo apt-get -y install nodejs-legacy npm
|
sudo apt-get -y install nodejs-legacy npm
|
||||||
cd /vagrant/yunohost-admin/src
|
cd ${BASE_INSIDE_VM}/yunohost-admin/src
|
||||||
sudo npm install
|
sudo npm install
|
||||||
sudo npm install -g bower
|
sudo npm install -g bower
|
||||||
sudo npm install -g gulp
|
sudo npm install -g gulp
|
||||||
fi
|
fi
|
||||||
cd /vagrant/yunohost-admin/src
|
cd ${BASE_INSIDE_VM}/yunohost-admin/src
|
||||||
sudo su -c "bower install" vagrant
|
sudo su -c "bower install" vagrant
|
||||||
sudo su -c "gulp build --dev" vagrant
|
sudo su -c "gulp build --dev" vagrant
|
||||||
|
|
||||||
echo "Using Git repository for yunohost-admin"
|
echo "Using Git repository for yunohost-admin"
|
||||||
create_sym_link "/vagrant/yunohost-admin/src" "/usr/share/yunohost/admin"
|
create_sym_link "${BASE_INSIDE_VM}/yunohost-admin/src" "/usr/share/yunohost/admin"
|
||||||
|
|
||||||
echo "--------------------------------------------------------"
|
echo "--------------------------------------------------------"
|
||||||
echo "Launching gulp ... "
|
echo "Launching gulp ... "
|
||||||
echo "NB : This command will keep running and watch for changes"
|
echo "NB : This command will keep running and watch for changes"
|
||||||
echo " in the folder /vagrant/yunohost-admin/src, such that you"
|
echo " in the folder ${BASE_INSIDE_VM}/yunohost-admin/src, such that you"
|
||||||
echo "don't need to re-run npm yourself everytime you change"
|
echo "don't need to re-run npm yourself everytime you change"
|
||||||
echo "something !"
|
echo "something !"
|
||||||
echo "--------------------------------------------------------"
|
echo "--------------------------------------------------------"
|
||||||
|
@ -306,63 +399,89 @@ elif [ "$1" = "use-git" ]; then
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Run tests for a given package #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
elif [ "$1" = "test" ]; then
|
readonly PIP_DEPENDENCIES_FOR_TESTS="pytest-mock requests-mock"
|
||||||
check_yunohost_vm
|
|
||||||
VERSION=$2
|
|
||||||
|
|
||||||
for i in ${!packages[@]}; do
|
install_or_update_test_dependencies()
|
||||||
case ${packages[i]} in
|
{
|
||||||
|
# Pytest
|
||||||
|
if ! type "pytest" > /dev/null; then
|
||||||
|
echo "======================="
|
||||||
|
echo "> Installing pytest ..."
|
||||||
|
echo "======================="
|
||||||
|
apt-get install python-pip
|
||||||
|
pip2 install pytest
|
||||||
|
fi
|
||||||
|
for DEP in "$PIP_DEPENDENCIES_FOR_TESTS"
|
||||||
|
do
|
||||||
|
# Install this dependency if it's not already there
|
||||||
|
is_not_empty_string "$(pip show $DEP)" || {
|
||||||
|
echo "======================="
|
||||||
|
echo "Installing $DEP with pip"
|
||||||
|
echo "======================="
|
||||||
|
pip2 install $DEP
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
# Apps for test
|
||||||
|
cd ${BASE_INSIDE_VM}/yunohost/src/yunohost/tests
|
||||||
|
if [ ! -d "apps" ]; then
|
||||||
|
git clone https://github.com/YunoHost/test_apps ./apps
|
||||||
|
else
|
||||||
|
cd apps
|
||||||
|
git pull > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_tests()
|
||||||
|
{
|
||||||
|
PACKAGES="$@"
|
||||||
|
|
||||||
|
assert_inside_yunohost_vm
|
||||||
|
install_or_update_test_dependencies
|
||||||
|
is_not_empty_string "$PACKAGES" || PACKAGES=${KNOWN_PACKAGES}
|
||||||
|
|
||||||
|
for PACKAGE in $PACKAGES; do
|
||||||
|
assert_package_is_known $PACKAGE
|
||||||
|
echo "Running tests for $PACKAGE"
|
||||||
|
case "$PACKAGE" in
|
||||||
yunohost)
|
yunohost)
|
||||||
# Pytest and tests dependencies
|
|
||||||
if ! type "pytest" > /dev/null; then
|
|
||||||
echo "======================="
|
|
||||||
echo "> Installing pytest ..."
|
|
||||||
echo "======================="
|
|
||||||
apt-get install python-pip
|
|
||||||
pip2 install pytest
|
|
||||||
fi
|
|
||||||
PIP_DEPENDENCIES="pytest-mock requests-mock"
|
|
||||||
for DEP in $PIP_DEPENDENCIES
|
|
||||||
do
|
|
||||||
if [ -z "$(pip show $DEP)" ]; then
|
|
||||||
echo "======================="
|
|
||||||
echo "Installing $DEP with pip"
|
|
||||||
echo "======================="
|
|
||||||
pip2 install $DEP
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Apps for test
|
|
||||||
cd /vagrant/yunohost/src/yunohost/tests
|
|
||||||
if [ ! -d "apps" ]; then
|
|
||||||
git clone https://github.com/YunoHost/test_apps ./apps
|
|
||||||
else
|
|
||||||
cd apps
|
|
||||||
git pull > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
echo "Running tests for YunoHost"
|
cd ${BASE_INSIDE_VM}/yunohost/
|
||||||
cd /vagrant/yunohost/
|
|
||||||
py.test tests
|
py.test tests
|
||||||
cd /vagrant/yunohost/src/yunohost
|
cd ${BASE_INSIDE_VM}/yunohost/src/yunohost
|
||||||
py.test tests
|
py.test tests
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Self-update #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
elif [ "$1" = "self-update" ]; then
|
self_update()
|
||||||
check_yunohost_vm
|
{
|
||||||
cd /vagrant/vagrant && git pull origin master
|
assert_inside_yunohost_vm
|
||||||
cd /vagrant/ynh-dev-tools && git pull origin master && cp ynh-dev ../ynh-dev
|
cd ${BASE_INSIDE_VM}/vagrant && git pull origin master
|
||||||
|
cd ${BASE_INSIDE_VM}/ynh-dev-tools && git pull origin master && cp ynh-dev ../ynh-dev
|
||||||
|
}
|
||||||
|
|
||||||
# Fallback to print usage
|
###############################################################################
|
||||||
else
|
# Main #
|
||||||
usage
|
###############################################################################
|
||||||
exit 101
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0;
|
main()
|
||||||
|
{
|
||||||
|
local ACTION="$1"
|
||||||
|
local ARGUMENTS="${@:2}"
|
||||||
|
|
||||||
|
execute_action "$ACTION" "$ARGUMENTS"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
Loading…
Add table
Reference in a new issue