parent
655024bfb1
commit
591a33f96e
|
@ -2,6 +2,5 @@
|
|||
|
||||
set -e
|
||||
|
||||
echo "Fetching event inventory"
|
||||
|
||||
echo "Fetching event inventory from Ambrose's infrastructure"
|
||||
ssh saguaro /usr/local/bin/wireguard-negotiator dump -i wg1 | go run event-generate.go opentech > event
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"net"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -21,24 +22,34 @@ func main() {
|
|||
|
||||
for s.Scan() {
|
||||
host := s.Text()
|
||||
if strings.HasPrefix(host, "#") {
|
||||
// Is a comment
|
||||
ip := net.ParseIP(host).To16()
|
||||
if ip == nil {
|
||||
// Not a valid IPv6, skip
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(host, ":0") {
|
||||
// Is a "system" host
|
||||
if !bytes.Equal(ip[8:14], []byte{0, 0, 0, 0, 0, 0}) {
|
||||
// First subnet is the recorders subnet
|
||||
// Other subnets are "system" hosts
|
||||
continue
|
||||
}
|
||||
hostname, roomId, roomType, err := discover(host, user)
|
||||
hostname, roomType, roomId, webcamName, err := discover(host, user)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "host %s discovery failed: %v\n", host, err)
|
||||
}
|
||||
fmt.Printf("%s ansible_host=%s ansible_user=%s room_id=%s room_type=%s\n", hostname, host, user, roomId, roomType)
|
||||
fmt.Printf("%s ansible_host=%s ansible_user=%s room_type=%s room_id=%s webcam_name=%s\n", hostname, host, user, roomType, roomId, webcamName)
|
||||
}
|
||||
}
|
||||
|
||||
func discover(host, user string) (hostname, roomId, roomType string, err error) {
|
||||
cmd := exec.Command("/usr/bin/ssh", "-l", user, host, "sh", "-c", "hostname; cat room_type; cat room_id; exit 0")
|
||||
const script = `
|
||||
hostname;
|
||||
(cat room_type || echo) | head -n 1;
|
||||
(cat room_id || echo) | head -n 1;
|
||||
(ls /dev/v4l/by-id/ | grep C920 | grep index0 || echo) | cut -d - -f 1,2 | head -n 1;
|
||||
(cat /sys/class/net/en*/address || echo) | head -n 1;
|
||||
`
|
||||
|
||||
func discover(host, user string) (hostname, roomType, roomId, webcamName string, err error) {
|
||||
cmd := exec.Command("/usr/bin/ssh", "-l", user, host, "sh", "-c", script)
|
||||
fmt.Fprintf(os.Stderr, "command: %s\n", cmd)
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
|
@ -55,5 +66,7 @@ func discover(host, user string) (hostname, roomId, roomType string, err error)
|
|||
roomType = strings.TrimSpace(roomType)
|
||||
roomId, _ = out.ReadString('\n')
|
||||
roomId = strings.TrimSpace(roomId)
|
||||
webcamName, _ = out.ReadString('\n')
|
||||
webcamName = strings.TrimSpace(webcamName)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
|
||||
room_type: unknown
|
||||
room_id: unknown
|
||||
|
||||
# Overwrite in inventory if cannot cope
|
||||
|
@ -7,9 +8,6 @@ record_profile: 720p
|
|||
# Overwrite in inventory if want to use more storage to use less CPU
|
||||
record_fast: false
|
||||
|
||||
record_user: mixer
|
||||
record_home: /home/mixer
|
||||
|
||||
# Set to 2 to enable monitoring, 0 to disable
|
||||
monitoring_type: 2
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ logo='/opt/login-logo.png'
|
|||
# disable-restart-buttons=true
|
||||
# - Show a login welcome message
|
||||
banner-message-enable=true
|
||||
banner-message-text='Hostname: {{ ansible_hostname }}\nUsername: opentech Password: opentech\nUsername: mixer Password: mixer\n{% if autostart %}Mixer Autostart Enabled{% endif %}'
|
||||
banner-message-text='Hostname: {{ ansible_hostname }}\n{% if room_type %}Room: {{ room_type }} {{ room_id }}{% endif %}\nUsername: opentech Password: opentech\nUsername: mixer Password: mixer\n{% if autostart %}Mixer Autostart Enabled{% endif %}'
|
||||
|
||||
# Automatic suspend
|
||||
# =================
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
127.0.0.1 localhost room-{{ room_id }}
|
||||
::1 localhost ip6-localhost ip6-loopbac room-{{ room_id }}
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
|
@ -102,11 +102,11 @@
|
|||
{% if room_type == "setup1" %}
|
||||
"device_id": "alsa_input.pci-0000_00_1b.0.analog-stereo"
|
||||
{% elif room_type == "setup2" %}
|
||||
"device_id": "alsa_input.usb-046d_HD_Pro_Webcam_C920_CEB3336F-02.analog-stereo"
|
||||
"device_id": "alsa_input.{{ webcam_name }}-02.analog-stereo"
|
||||
{% elif room_type == "setup3" %}
|
||||
"device_id": "alsa_input.usb-046d_HD_Pro_Webcam_C920_CEB3336F-02.analog-stereo"
|
||||
"device_id": "alsa_input.{{ webcam_name }}-02.analog-stereo"
|
||||
{% else %}
|
||||
"device_id": "alsa_input.usb-046d_HD_Pro_Webcam_C920_CEB3336F-02.analog-stereo"
|
||||
"device_id": "alsa_input.{{ webcam_name }}-02.analog-stereo"
|
||||
{% endif %}
|
||||
},
|
||||
"sync": 0,
|
||||
|
@ -1011,11 +1011,11 @@
|
|||
{% if room_type == "setup1" %}
|
||||
"device_id": "/dev/v4l/by-path/pci-0000:00:14.0-usb-0:2:1.0-video-index0",{# X230 LEFT FRONT PORT #}
|
||||
{% elif room_type == "setup2" %}
|
||||
"device_id": "/dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_CEB3336F-video-index0",
|
||||
"device_id": "/dev/v4l/by-id/usb-{{ webcam_name }}-video-index0",
|
||||
{% elif room_type == "setup3" %}
|
||||
"device_id": "/dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_CEB3336F-video-index0",
|
||||
"device_id": "/dev/v4l/by-id/usb-{{ webcam_name }}-video-index0",
|
||||
{% else %}
|
||||
"device_id": "/dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_CEB3336F-video-index0",
|
||||
"device_id": "/dev/v4l/by-id/usb-{{ webcam_name }}-video-index0",
|
||||
{% endif %}
|
||||
"framerate": 65566,
|
||||
"input": 0,
|
||||
|
|
Loading…
Reference in New Issue