This commit is contained in:
Alexandre Aubin 2018-09-04 00:15:58 +02:00
parent c938674431
commit 99cba1e489
4 changed files with 53 additions and 42 deletions

8
Vagrantfile vendored
View file

@ -4,11 +4,11 @@
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2" VAGRANTFILE_API_VERSION = "2"
NETWORK = "192.168.33." NETWORK = "10.0.3."
HOSTS = { HOSTS = {
"ynh-dev" => ["83", "stretch-unstable"], "ynh-dev" => ["83", "ynh-dev"],
"ynh-dev-buster" => ["84", "buster-unstable"], "ynh-dev-buster" => ["84", "ynh-dev-buster"],
} }
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@ -25,7 +25,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
machine.vm.guest = :debian machine.vm.guest = :debian
machine.vm.provider "lxc" do |lxc| machine.vm.provider "lxc" do |lxc|
config.vm.box_url = "https://build.yunohost.org/yunohost-" + version + "-lxc.box" config.vm.box_url = "https://build.yunohost.org/" + version + "-lxc.box"
config.vm.synced_folder ".", "/ynh-dev", id: "vagrant-root" config.vm.synced_folder ".", "/ynh-dev", id: "vagrant-root"
config.vm.network :private_network, ip: NETWORK + ipaddr, lxc__bridge_name: 'lxcbr0' config.vm.network :private_network, ip: NETWORK + ipaddr, lxc__bridge_name: 'lxcbr0'
end end

View file

@ -8,7 +8,7 @@ set -x
sudo apt-get install vagrant lxc git -y sudo apt-get install vagrant lxc git -y
git clone https://github.com/YunoHost/ynh-dev git clone https://github.com/alexAubin/ynh-dev
cd ./ynh-dev cd ./ynh-dev
git clone https://github.com/YunoHost/moulinette git clone https://github.com/YunoHost/moulinette
git clone https://github.com/YunoHost/yunohost git clone https://github.com/YunoHost/yunohost

View file

@ -1,23 +1,19 @@
#!/bin/bash #!/bin/bash
DEBIAN_VERSION="stretch"
YNH_VERSION="unstable"
PROVIDER="lxc"
# Compute box name # Compute box name
BOX="$DEBIAN_VERSION-$YNH_VERSION" BOX="ynh-dev"
# Create box # Create box
vagrant up $BOX --provider $PROVIDER vagrant up $BOX
# Package box # Package box
vagrant package $BOX --output /tmp/yunohost-$BOX-$PROVIDER.box vagrant package $BOX --output /tmp/$BOX.box
# Destroy current box # Destroy current box
vagrant destroy $BOX vagrant destroy $BOX
# User message, and exit # User message, and exit
echo "" echo ""
echo "Your Vagrant box was packaged to /tmp/yunohost-$BOX-$PROVIDER.box" echo "Your Vagrant box was packaged to /tmp/$BOX.box"
echo "You might want to run : vagrant box add "yunohost/$BOX" /tmp/yunohost-$BOX-$PROVIDER.box" echo "You might want to run : vagrant box add 'yunohost/ynh-dev' /tmp/$BOX.box"
exit exit

71
ynh-dev
View file

@ -4,32 +4,21 @@ readonly THISSCRIPT=`basename $0`
function show_usage() { function show_usage() {
cat <<EOF cat <<EOF
Usage :
On the host ${BLUE}On the host, to manage the LXC${NORMAL}
=========== ${BLUE}==============================${NORMAL}
$THISSCRIPT start start (Create and) starts the ynh-dev LXC
(Create and) starts the ynh-dev LXC ssh SSH into an already started ynh-dev LXC
destroy Destroy the ynh-dev LXC
rebuild Rebuild a fresh, up-to-date box
$THISSCRIPT ssh ${BLUE}Inside the dev instance${NORMAL}
SSH into an already started ynh-dev LXC ${BLUE}=======================${NORMAL}
$THISSCRIPT destroy ip Give the ip of the guest container
Destroy the ynh-dev LXC use-git [PKG] Use Git repositories from dev environment path
test [PKG] Deploy, update and run tests for some packages
$THISSCRIPT rebuild
Rebuild a fresh, up-to-date box
Inside the vm
=============
$THISSCRIPT ip
Give the ip of the guest container
$THISSCRIPT use-git [PACKAGES [PACKAGES ...]]
Use Git repositories from dev environment path
$THISSCRIPT test [PACKAGES [PACKAGES ...]]
Deploy, update and run tests for some packages
EOF EOF
} }
@ -39,6 +28,8 @@ function main()
local ACTION="$1" local ACTION="$1"
local ARGUMENTS="${@:2}" local ARGUMENTS="${@:2}"
[ -z "$ACTION" ] && show_usage && exit 0
case "${ACTION}" in case "${ACTION}" in
help|-h|--help) show_usage $ARGUMENTS ;; help|-h|--help) show_usage $ARGUMENTS ;;
@ -122,25 +113,26 @@ function create_sym_link() {
function start_ynhdev() function start_ynhdev()
{ {
BOX_NAME="yunohost/strech-unstable" local BOX_NAME="yunohost/ynh-dev"
BOX_URL="https://build.yunohost.org/yunohost-$BOX_NAME-lxc.box" local BOX_URL="https://build.yunohost.org/yunohost-$BOX_NAME-lxc.box"
set -eu
# 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
info "Vagrant box '$BOX_NAME' is missing. Trying to download it" info "Vagrant box '$BOX_NAME' is missing. Trying to download it"
vagrant box add $BOX_NAME $BOX_URL --provider $PROVIDER vagrant box add $BOX_NAME $BOX_URL
fi fi
# Run VM # Run VM
vagrant up ynh-dev --provider lxc vagrant up ynh-dev
# Log into the VM # Log into the VM
vagrant ssh ynh-dev -c "sudo -i" ssh_ynhdev
} }
function ssh_ynhdev() function ssh_ynhdev()
{ {
vagrant ssh ynh-dev -c "sudo -i" vagrant ssh ynh-dev -c "echo 'You are now inside the LXC !'; cd /ynh-dev; sudo su"
} }
function destroy_ynhdev() function destroy_ynhdev()
@ -148,6 +140,29 @@ function destroy_ynhdev()
vagrant destroy ynh-dev vagrant destroy ynh-dev
} }
function rebuild_ynhdev()
{
local BOX="ynh-dev"
set -x
cd prebuild
# Create box
vagrant up $BOX
# Package box
vagrant package $BOX --output /tmp/$BOX.box
# Destroy current box
vagrant destroy $BOX
set +x
# User message, and exit
info "The Vagrant box was packaged to /tmp/$BOX.box"
info "You might want to run : vagrant box add 'yunohost/ynh-dev' /tmp/$BOX.box"
}
function show_vm_ip() function show_vm_ip()
{ {
assert_inside_vm assert_inside_vm