Compare commits
1 commit
master
...
ubuntu-ima
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a02a5714f |
8 changed files with 13 additions and 129 deletions
|
|
@ -3,8 +3,8 @@
|
|||
set -e
|
||||
set -x
|
||||
|
||||
MAJOR_VERSION=3.11
|
||||
MINOR_VERSION=2
|
||||
MAJOR_VERSION=3.10
|
||||
MINOR_VERSION=3
|
||||
IMAGE=alpine-minirootfs-$MAJOR_VERSION.$MINOR_VERSION-x86_64.tar.gz
|
||||
SSH_KEYS=$(cat ~/.ssh/id_rsa.pub)
|
||||
RESOLVCONF=/etc/resolv.conf
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#option $3 is DB user
|
||||
#option $4 is DB name
|
||||
|
||||
#host='localhost'
|
||||
host='localhost'
|
||||
|
||||
user_arr=( $(cat $1 | awk '{print $1}' ))
|
||||
vmid_arr=( $(cat $1 | awk '{print $2}' ))
|
||||
|
|
@ -24,17 +24,15 @@ for ((i=0; i<${#user_arr[@]}; i++)) do
|
|||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection (connection_name, protocol) VALUES ('$cn', 'vnc');"
|
||||
cn_id=$(psql -h $2 -U $3 -d $4 -tAc "SELECT MAX(connection_id) FROM guacamole_connection WHERE connection_name = '$cn' AND parent_id IS NULL;")
|
||||
|
||||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection_parameter VALUES ('$cn_id','hostname','${place_arr[i]}');"
|
||||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection_parameter VALUES ('$cn_id','hostname','$host');"
|
||||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection_parameter VALUES ('$cn_id','port','${port_arr[i]}');"
|
||||
|
||||
#connection permission
|
||||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection_permission(entity_id, connection_id, permission) VALUES ('$en_id', '$cn_id', 'READ');"
|
||||
#clipboard-encoding
|
||||
psql -h $2 -U $3 -d $4 -tAc "INSERT INTO guacamole_connection_parameter VALUES ('$cn_id','clipboard-encoding','UTF-8');"
|
||||
|
||||
else
|
||||
cn_id=$(psql -h $2 -U $3 -d $4 -tAc "SELECT MAX(connection_id) FROM guacamole_connection WHERE connection_name = '$cn' AND parent_id IS NULL;")
|
||||
psql -h $2 -U $3 -d $4 -tAc "UPDATE guacamole_connection_parameter SET parameter_value='${place_arr[i]}' where connection_id='$cn_id' and parameter_name='hostname';"
|
||||
psql -h $2 -U $3 -d $4 -tAc "UPDATE guacamole_connection_parameter SET parameter_value='$host' where connection_id='$cn_id' and parameter_name='hostname';"
|
||||
psql -h $2 -U $3 -d $4 -tAc "UPDATE guacamole_connection_parameter SET parameter_value='${port_arr[i]}' where connection_id='$cn_id' and parameter_name='port';"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# Nico Schottelius, 2020-01-07
|
||||
# Detect the DNS64 prefix
|
||||
# Based on https://tools.ietf.org/html/draft-ietf-behave-nat64-discovery-heuristic-05
|
||||
#
|
||||
# How it works:
|
||||
# - ipv4only.arpa only has A records.
|
||||
# - a DNS64 server will add AAAA records
|
||||
# - we take this response (if any) and derive the IPv6 prefix from it
|
||||
#
|
||||
|
||||
import dns.resolver
|
||||
import ipaddress
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
dns64_prefix = None
|
||||
answers = dns.resolver.query('ipv4only.arpa', 'AAAA')
|
||||
|
||||
for rdata in answers:
|
||||
address = str(rdata)
|
||||
network = ipaddress.IPv6Network("{}/96".format(address),
|
||||
strict=False)
|
||||
# print("{}: {}".format(rdata, network))
|
||||
print("{}".format(network))
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# List mail addresses found under base DN $1 (defaults to dc=ungleich,dc=ch)
|
||||
|
||||
set -e
|
||||
|
||||
# Hardcoded parameters.
|
||||
LDAP_SERVER="ldaps://ldap1.ungleich.ch"
|
||||
LDAP_BIND_DN="cn=manager,dc=ungleich,dc=ch"
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
LDAP_SEARCH_BASE="$1"
|
||||
else
|
||||
LDAP_SEARCH_BASE="dc=ungleich,dc=ch"
|
||||
fi
|
||||
|
||||
# Read secrets from environment.
|
||||
if [ "$LDAP_BIND_PASSWD" = "" ]; then
|
||||
echo "You have to define LDAP_BIND_PASSWD before launching this script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract mail addresses from LDAP directory.
|
||||
ldap_search_result="$(
|
||||
ldapsearch -x -H "$LDAP_SERVER" \
|
||||
-D "$LDAP_BIND_DN" \
|
||||
-w "$LDAP_BIND_PASSWD" \
|
||||
-b "$LDAP_SEARCH_BASE" mail
|
||||
)"
|
||||
|
||||
echo "$ldap_search_result" | grep 'mail:' | cut -d ' ' -f 2 -
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This script extract VM IDs and filter them if a pattern is provided as first
|
||||
# argument.
|
||||
|
||||
set -e
|
||||
|
||||
# Extract instances from ONE.
|
||||
instances=$(onevm list --csv | tail -n +2)
|
||||
|
||||
# Filter them is a pattern has been provided.
|
||||
if [ "$1" != "" ]; then
|
||||
filtered_instances="$(echo "$instances" | grep -E "$1")"
|
||||
instances="$filtered_instances"
|
||||
fi
|
||||
|
||||
# Outputs instance IDs.
|
||||
echo "$instances" | cut -d ',' -f 1 -
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This script is expected to run on the ONE server (i.e.
|
||||
# opennebula.ungleich.ch).
|
||||
|
||||
set -e
|
||||
|
||||
# Fetch instance list from STDIN.
|
||||
instances=$(cat -)
|
||||
|
||||
# For every instance, extract relevant information:
|
||||
for id in $instances; do
|
||||
nics_raw="$(onevm show --xml $id | xml_grep 'NIC')"
|
||||
networks="$(echo $nics_raw | xml_grep --text_only 'NETWORK' | tr '\n' ',' | sed 's/,$//')"
|
||||
ip="$(echo $nics_raw | xml_grep --text_only 'IP' | tr '\n' ',' | sed 's/,$//')"
|
||||
ip6="$(echo $nics_raw | xml_grep --text_only 'IP6_GLOBAL' | tr '\n' ',' | sed 's/,$//')"
|
||||
echo "$id,$networks,$ip,$ip6"
|
||||
done
|
||||
|
|
@ -1,19 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script generates Ubuntu images for OpenNebula.
|
||||
#
|
||||
# Test image locally (without network) with:
|
||||
|
||||
# Depends on the following packages (as of Ubuntu 19.04):
|
||||
# debootstrap
|
||||
|
||||
# Run locally (without network) with:
|
||||
# qemu-system-x86_64 -enable-kvm -m 1G -drive file=$IMAGE,format=qcow2
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# XXX: Handle command-line arguments?
|
||||
RELEASE=focal # 20.04
|
||||
RELEASE=eoan # 19.10
|
||||
ARCH=amd64
|
||||
IMAGE_PATH=ubuntu-$RELEASE-$(date --iso-8601).img.qcow2
|
||||
IMAGE_SIZE=10G
|
||||
NBD_DEVICE=/dev/nbd0
|
||||
NBD_DEVICE=/dev/nbd2
|
||||
|
||||
# TODO: find the package definition and built ourself, publish in some RPM repository.
|
||||
ONE_CONTEXT_DEB_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context_5.10.0-1.deb"
|
||||
|
|
@ -54,9 +57,6 @@ qemu-img create -f qcow2 "$IMAGE_PATH" "$IMAGE_SIZE"
|
|||
modprobe nbd max_part=16
|
||||
qemu-nbd --connect="$NBD_DEVICE" "$IMAGE_PATH"
|
||||
|
||||
# Wait for qemu-nbd to settle.
|
||||
sleep 1
|
||||
|
||||
# Don't forget to cleanup, even if the script crash.
|
||||
trap cleanup EXIT
|
||||
|
||||
|
|
@ -113,9 +113,6 @@ curl -L "$ONE_CONTEXT_DEB_URL" > "/mnt$ONE_CONTEXT_DEB_PATH"
|
|||
run_root apt-get -y install "$ONE_CONTEXT_DEB_PATH"
|
||||
run_root rm "$ONE_CONTEXT_DEB_PATH"
|
||||
|
||||
# Manually install legacy network scripts used by one-context.
|
||||
run_root apt-get -y install ifupdown
|
||||
|
||||
# Initalize base services.
|
||||
run_root systemd-machine-id-setup
|
||||
|
||||
|
|
@ -132,6 +129,7 @@ run_root grub-mkconfig -o /boot/grub/grub.cfg
|
|||
|
||||
# Install en configure SSH daemon.
|
||||
run_root apt-get -y install openssh-server
|
||||
run_root systemctl enable sshd
|
||||
|
||||
# Generate fstab file.
|
||||
boot_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p1")
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
#option $1 is ldap password
|
||||
#option $2 is ou
|
||||
|
||||
|
||||
uid_list=( $(ldapsearch -x -H ldaps://ldap1.ungleich.ch:636 -D cn=manager,dc=ungleich,dc=ch -w $1 -b "ou=$2,dc=ungleich,dc=ch" | grep uid: | awk '{print $2}') )
|
||||
|
||||
for ((i=0; i<${#uid_list[@]}; i++)) do
|
||||
uid_temp=$(echo ${uid_list[i]} | sed "s/b'//g" | sed "s/'//g")
|
||||
list_email[$i]=$(ldapsearch -x -H ldaps://ldap1.ungleich.ch:636 -D cn=manager,dc=ungleich,dc=ch -w $1 -b "uid=${uid_list[$i]},ou=$2,dc=ungleich,dc=ch" | grep mail: | awk '{print $2}' )
|
||||
list_vmid=()
|
||||
list_vmid=( $(onevm list | grep ${list_email[$i]} | grep runn | awk '{print $1}' ) )
|
||||
for ((j=0; j<${#list_vmid[@]}; j++)) do
|
||||
temp=$(onevm show ${list_vmid[$j]} | grep PORT)
|
||||
temp1="${temp#*\"}"
|
||||
port="${temp1%%\"*}"
|
||||
host=$(onevm show ${list_vmid[$j]} | grep HOST | grep ungleich | awk '{print $3}')
|
||||
echo $uid_temp ${list_vmid[$j]} $port $host >> ~/vm_vnc_list
|
||||
done
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue