[enh] work in progress

This commit is contained in:
alban 2020-09-23 18:56:10 +02:00
parent 9be801f790
commit 9fd6ecfcdb
3 changed files with 142 additions and 25 deletions

View File

@ -10,18 +10,18 @@
{ {
"type": "lxc", "type": "lxc",
"name": "buster-lxc", "name": "teamlaser-lj-lxc",
"config_file": "files/lxc/config", "config_file": "files/lxc/config",
"template_name": "debian", "template_name": "debian",
"template_environment_vars": ["SUITE=buster"], "template_environment_vars": ["SUITE=buster"],
"output_directory": "output" "output_directory": "output-lxc"
}, },
{ {
"headless": false, "headless": false,
"name": "buster-kvm", "name": "teamlaser-lj",
"type": "qemu", "type": "qemu",
"format": "qcow2", "format": "qcow2",
"accelerator": "kvm", "accelerator": "kvm",
@ -35,6 +35,41 @@
"ssh_password": "{{ user `password` }}", "ssh_password": "{{ user `password` }}",
"shutdown_command": "echo '{{ user `password` }}' | sudo -S shutdown -h now", "shutdown_command": "echo '{{ user `password` }}' | sudo -S shutdown -h now",
"ssh_wait_timeout": "60m",
"qemuargs": [
[ "-m", "2048M" ]
],
"boot_wait": "2s",
"boot_command": [
"<esc><wait><wait>",
"install ",
"auto=true ",
"priority=critical ",
"interface=auto ",
"url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>",
"<enter>"
]
},
{
"headless": false,
"name": "teamlaser-lj-xfce",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size` }}",
"output_directory": "output-xfce",
"boot_key_interval": "20ms",
"iso_url": "http://cdimage.debian.org/debian-cd/10.5.0/amd64/iso-cd/debian-10.5.0-amd64-xfce-CD-1.iso",
"iso_checksum": "sha256:14ca00bafcaf124ef2cab9da2f51d75044232ba9630a067d8664fabcb5e26ec2",
"http_directory": "http",
"ssh_username": "{{ user `user` }}",
"ssh_password": "{{ user `password` }}",
"shutdown_command": "echo '{{ user `password` }}' | sudo -S shutdown -h now",
"ssh_wait_timeout": "60m", "ssh_wait_timeout": "60m",
"qemuargs": [ "qemuargs": [
[ "-m", "2048M" ] [ "-m", "2048M" ]
@ -59,34 +94,25 @@
"inline": [ "inline": [
"sleep 3", "sleep 3",
"apt update", "apt update",
"apt install -y --no-install-recommends git htop libasound2-dev libjack-dev libsdl1.2-dev nginx python3-dev python3-pip python3-rtmidi redis-server screen ssh syncthing supervisor tmux portaudio19-dev cmake ", "apt install -y --no-install-recommends cmake git libasound2-dev libjack-dev libsdl1.2-dev network-manager nginx portaudio19-dev python3-dev python3-pip python3-rtmidi redis-server screen ssh ssl-cert ",
"systemctl disable network-manager.service",
"pip3 install setuptools", "pip3 install setuptools",
"pip3 install DMXEnttecPro mido numpy pysimpledmx redis scipy " "pip3 install DMXEnttecPro mido numpy pysimpledmx redis scipy ",
"git clone https://github.com/ptone/pyosc --depth 1 /tmp/pyosc && cd /tmp/pyosc && ./setup.py install ",
"cd /tmp && git clone https://github.com/Ableton/link.git && cd link && git submodule update --init --recursive && mkdir build && cd build && cmake .. && cmake --build . ",
"cd /tmp/ && git clone --recursive https://github.com/gonzaloflirt/link-python.git && cd link-python && mkdir build && cd build && cmake .. && cmake --build . ",
"cd /opt/ && git clone https://git.interhacker.space/teamlaser/LJ "
] ]
}, },
{ {
"type": "file", "type": "file",
"source": "files/supervisor-syncthing.conf", "source": "files/nginx/laser.conf",
"destination": "/etc/supervisor/conf.d/supervisor-syncthing.conf" "destination": "/etc/nginx/sites-enabled/laser.conf"
}, },
{ {
"type": "shell", "type": "file",
"inline": [ "source": "files/root/.bashrc",
"git clone https://github.com/ptone/pyosc --depth 1 /tmp/pyosc && cd /tmp/pyosc && ./setup.py install " "destination": "/root/.bashrc"
]
},
{
"type": "shell",
"inline": [
"cd /tmp && git clone https://github.com/Ableton/link.git && cd link && git submodule update --init --recursive && mkdir build && cd build && cmake .. && cmake --build . "
]
},
{
"type": "shell",
"inline": [
"cd /tmp/ && git clone --recursive https://github.com/gonzaloflirt/link-python.git && cd link-python && mkdir build && cd build && cmake .. && cmake --build . "
]
} }
] ]
} }

12
files/nginx/laser.conf Normal file
View File

@ -0,0 +1,12 @@
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
server_name _;
root /opt/LJ/www;
index index.html index.htm index.nginx-debian.html;
}

79
files/root/.bashrc Normal file
View File

@ -0,0 +1,79 @@
cd /opt/LJ
echo -e "\n\e[1;31m"
cat << HEREDOC
\ \ / | | | |
\ \ \ / _ \ | __| _ \ __ \__ \ _ \ __| _ \ | |
\ \ \ / __/ | ( ( | | | | __/ | ( | | \ |
\_/\_/ \___| _| \___| \___/ _| _| _| \___| \__| \___/ _____| \___/
HEREDOC
echo -e "\e[0m\n"
# Check the ip address on the machine
checkNetwork(){
ping=$( ping 1.1.1.1 -c 1 -W 2 &>/dev/null; echo $?;)
# Net is working, escape
[[ 0 -eq $ping ]] && return
echo -e "\nOops... No network configured yet..."
# Eventually, use nm-tui for a graphical (ncurses install)
read -e -p "Do you want to set up network via the ncurses tool? [yN]: "
[[ "${REPLY^^}" == "Y" ]] && { nmtui; return; }
# Get the ethernet interface
# 772 is the loopback device, cf. http://lxr.linux.no/linux+v3.0/include/linux/if_arp.h#L67
for f in /sys/class/net/* ; do
[[ 772 != $(cat "$f/type" ) ]] && interface=$(basename $f)
done
[[ -z "$interface" ]] && { echo -e "\e[31mFatal Error : no network interface configured."; return; }
echo "Found network interface '$interface'"
# Ensure the interface is up
ip l set $interface up
ipList=$( ip address show | grep global )
ipRoute=$( ip route show | grep default )
[[ -z "$ipList" ]] && {
echo -e "\nNo IP address configured. Please set one."
read -e -i '192.168.2.100/24' -p "Which address/range do you want to use (or 'x' to skip)? " ipAddr
[[ 'x' != "$ipAddr" ]] && {
ip address add $ipAddr dev $interface
}
}
[[ -z "$ipRoute" ]] && {
echo -e "\nNo IP route configured. Please set one."
read -e -i '192.168.2.1' -p "Which routing address do you want to use (or 'x' to skip)? " ipAddr
[[ 'x' != "$ipAddr" ]] && {
ip route add default via $ipAddr dev $interface
}
}
}
checkNetwork
[[ ! -f /tmp/.first_run ]] && {
touch /tmp/.first_run ;
echo -e "\e[1mCaution! configuring the server and lasers network is mandatory for the app to work."
echo -e "Type the "c" key immediately to start the configuration."
echo -e "\e[0m"
echo -e "Everytime you will login, the configure and documentation options will be offered to you."
echo -e "Or use the commands 'config' or 'usage' any time to access the same functions."
echo -e "\e[0m"
}
config(){ cd /opt/LJ ; /usr/bin/python3 configure.py; }
usage(){ cat /opt/LJ/README.md; }
echo -e "\e[1m"
read -e -n 1 -p "Do you want to (c)onfigure the app, (r)ead documentation, or (n)othing: "
echo -e "\e[0m"
case $REPLY in
(c):
config
;;
(r):
usage
;;
esac