#cloud-config # vim: syntax=yaml # # BerryOS Default Cloud Config # # ## Set system hostname hostname: set_your_hostname_here # System hostname manage_etc_hosts: true # If true, will also update the /etc/hosts file entries # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#set-hostname # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#update-etc-hosts # ## Configure default user access password: set_your_password_here # Set default user password chpasswd: { expire: false } # Do not expire password after first login ssh_pwauth: true # Enable SSH password authentication for default user # ssh_authorized_keys: # Set SSH authorized keys for default user # - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAGEA3FSyQwBI6Z+nCSjUU ... # - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3I7VUf2l5gSn5uavROsc5HRDpZ ... # ssh_import_id: # Import SSH authorized keys from a remote source for default user # - gh:0rax # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#set-passwords # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#authorized-keys # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#ssh-import-id # ## Create your own user (overrides default user configuration) users: - default # - name: myuser # Create new custom user # gecos: "My Custom User" # Set user description # sudo: ALL=(ALL) NOPASSWD:ALL # Enable passwordless sudo # shell: /bin/bash # Set user default shell # groups: # Set user groups # [adm, dialout, cdrom, sudo, audio, video, plugdev, games, users, input, render, netdev] # passwd: berryos # Set user password # chpasswd: { expire: false } # Do not expire password after first login # ssh_pwauth: true # Allow SSH password auth for the user # ssh_authorized_keys: # Set SSH authorized keys for the user # - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAGEA3FSyQwBI6Z+nCSjUU ... # - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3I7VUf2l5gSn5uavROsc5HRDpZ ... # ssh_import_id: # Import SSH authorized keys from a remote source for the user # - gh:0rax # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#users-and-groups # ## Set the system timezone timezone: "Asia/Kuala_Lumpur" # Timezone value must exist in /usr/share/zoneinfo # ## Configure NTP pools ntp: enabled: true # Enable NTP module pools: # Specift custom pool uri - 0.my.pool.ntp.org - 1.my.pool.ntp.org - 2.my.pool.ntp.org - 3.my.pool.ntp.org # # Update package list, upgrade system or install new packages on first boot package_update: true # Update package list package_upgrade: true # Update system package on first-noot package_reboot_if_required: true # Reboot system after installing or upgrading if needed packages: # Install additional packages - vlc #Video player - screen #Linux terminal session manager - rsync #File synchroniser - cec-utils #CEC utility to manage tv via HDMI-CEC - fonts-arphic-ukai #Font to display chinese character on screen - sshpass # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#package-update-upgrade-install # ## Write custom files to disk write_files: - path: /opt/tv_video/videoloop.sh # File path permissions: "0777" # File permission owner: "root:root" # File ownership content: | # File content #!/bin/bash LOOP_PATH=/opt/tv_video/videos VLC_ARG="-I ncurses --loop $LOOP_PATH" startvlc() { stopvlc vlc $VLC_ARG } screen_start_vlc() { current=$(date '+%H%M') dow=$(date '+%u') WEEKDAYS_START_TIME=0630 WEEKDAYS_END_TIME=1500 WEEKEND_START_TIME=0600 WEEKEND_END_TIME=1300 if [[ $dow == [1-5] && $current > $WEEKDAYS_START_TIME && $current < WEEKDAYS_END_TIME ]] || [[ $dow == 6 && $current > $WEEKEND_START_TIME && $current < $WEEKEND_END_TIME ]]; then stopvlc screen -dmS videoloop vlc $VLC_ARG fi } stopvlc() { screen -XS videoloop quit pkill screen pkill vlc } if [[ "$1" == "stop" ]]; then stopvlc elif [[ "$1" == "rawstart" ]]; then startvlc else screen_start_vlc fi - path: /opt/tv_video/tv.sh permissions: "0777" owner: "root:root" content: | #!/bin/bash if [ "$(id -u)" -ne 0 ]; then echo "Please run as root." >&2; exit 1; fi RELAY_GPIO=17 OFF_STATE=1 ON_STATE=$(( OFF_STATE ^ 1 )) GPIO_PATH=/sys/class/gpio/gpio$RELAY_GPIO [[ -e $GPIO_PATH ]] || echo $RELAY_GPIO > /sys/class/gpio/export echo out > $GPIO_PATH/direction if [[ "$1" == "on" ]]; then echo $ON_STATE > $GPIO_PATH/value echo "on 0" | /usr/bin/cec-client -s -d 1 elif [[ "$1" == "off" ]]; then echo $OFF_STATE > $GPIO_PATH/value if [[ $(cat $GPIO_PATH/value) == $ON_STATE ]]; then echo "The relay can't be turned off, it might be forced to turn on" fi echo "off 0" | /usr/bin/cec-client -s -d 1 else echo "Please specify on or off" fi - path: /etc/cron.d/videoloop content: | # File content 31 06 * * 1-5 pi /opt/tv_video/videoloop.sh 31 06 * * 1-5 root /opt/tv_video/tv.sh on 59 15 * * 1-5 pi /opt/tv_video/videoloop.sh stop 59 15 * * 1-5 root /opt/tv_video/tv.sh off 01 06 * * 6 pi /opt/tv_video/videoloop.sh 01 06 * * 6 root /opt/tv_video/tv.sh on 59 13 * * 6 pi /opt/tv_video/videoloop.sh stop 59 13 * * 6 root /opt/tv_video/tv.sh off @reboot pi /opt/tv_video/videoloop.sh @reboot root /opt/tv_video/tv.sh on # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#write-files # ## Run commands on first boot (runs after all module) runcmd: - mkdir -p /opt/tv_video/videos && chmod -R 777 /opt/tv_video/videos - wget -O /opt/tv_video/drm-capture https://github.com/B83C/drm-vc4-grabber/releases/latest/download/drm-capture-aarch64 && chmod +x /opt/tv_video/drm-capture #Fetch latest olivetin from github since it is not added to main repo # - echo BerryOS # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#runcmd # ## Reboot system after provisioning power_state: mode: reboot # # Reference(s): # # - https://cloudinit.readthedocs.io/en/latest/topics/modules.html#power-state-change