diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d7ca5dc..5615bec8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,9 +33,9 @@ jobs: then flavors='{"flavor":"alpha 2Q"}' else - flavors='{"flavor":"2Q"},{"flavor":"2R"}' + flavors='{"flavor":"migrationOS"}' fi - echo "::set-output name=matrix::{\"include\":[$flavors]}" + echo "matrix={\"include\":[$flavors]}" >> $GITHUB_OUTPUT build: needs: set_matrix @@ -83,14 +83,14 @@ jobs: END - name: Checkout CustomPiOS - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: 'mrbeam/CustomPiOS' path: CustomPiOS ref: 'test_devpi_josef' - name: Checkout Project Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive path: repository @@ -115,11 +115,40 @@ jobs: run: | echo "OCTOPI_APTMIRROR=http://mirror.us.leaseweb.net/raspbian/raspbian" > repository/src/config.local + - name: Download the Beam OS 2 Image + uses: actions-hub/gcloud@master + env: + PROJECT_ID: devpi-310008 + APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DOWNLOAD }} + with: + args: cp "${{ vars.BEAMOS2_IMAGE }}" repository/src/image/ + cli: gsutil + + - name: Extract the Beam OS 2 Image + id: extract_the_image + run: | + # Set the image file + the_image=$(basename "${{ vars.BEAMOS2_IMAGE }}") + source_dir="repository/src/image" + echo "The Beam OS 2 Image: ${the_image}" + target_dir="repository/src/modules/beamos/filesystem/migration/home/pi/image" + target_name="beamos2.wic" + # Extract bz2 file into target_dir + tar -xjf ${source_dir}/${the_image} -C $target_dir + # Rename the extracted image to beamos2.wic[bz2, bmap] and remove other files + mv ${target_dir}/mrbeam-image-*.wic.bz2 ${target_dir}/${target_name}.bz2 + mv ${target_dir}/mrbeam-image-*.wic.bmap ${target_dir}/${target_name}.bmap + rm ${target_dir}/mrbeam-* + echo "Placed the image in ${target_dir}/${target_name}.bz2 with bmap file" + - name: Build Image (MrBeam Variant) + env: + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: | sudo modprobe loop cd repository/src echo "export EXTRA_SSH_KEY='${{ secrets.SSH_BEAMOS01_RSA }}'" >> config + echo "export PERSONAL_ACCESS_TOKEN='${{ secrets.PERSONAL_ACCESS_TOKEN }}'" >> config sudo bash -x ./build_dist $VARIANT ${{ matrix.flavor }} - name: Copy output @@ -142,7 +171,7 @@ jobs: cp repository/src/workspace/*.img $IMAGE.img fi - echo "::set-output name=image::$IMAGE" + echo "image=$IMAGE" >> $GITHUB_OUTPUT # # artifact upload will take care of zipping for us # - uses: actions/upload-artifact@v1 @@ -158,7 +187,7 @@ jobs: - name: Create env variable for upload folder in gcloud bucket run: | # Use the last letter of the flavor for the directory name - echo "DIR=$(echo ${{ matrix.flavor }} | rev | cut -c 1)" >> $GITHUB_ENV + echo "DIR=$(echo ${{ matrix.flavor }})" >> $GITHUB_ENV - uses: actions-hub/gcloud@master env: PROJECT_ID: devpi-310008 diff --git a/src/modules/beamos/config b/src/modules/beamos/config index 61a33c10..2fceb148 100755 --- a/src/modules/beamos/config +++ b/src/modules/beamos/config @@ -14,7 +14,7 @@ TRUE_USER=pi ## Dependencies [ -n "$BEAMOS_IOBEAM_REPO_BRANCH" ] || BEAMOS_IOBEAM_REPO_BRANCH=v1.3.1 [ -n "$BEAMOS_MRBHWINFO_REPO_BRANCH" ] || BEAMOS_MRBHWINFO_REPO_BRANCH=v1.0.0 -[ -n "$BEAMOS_MRBEAMLED_REPO_BRANCH" ] || BEAMOS_MRBEAMLED_REPO_BRANCH=v1.0.0 +[ -n "$BEAMOS_MRBEAMLED_REPO_BRANCH" ] || BEAMOS_MRBEAMLED_REPO_BRANCH=v2.1.0a0 [ -n "$BEAMOS_NETCONNECTD_REPO_BRANCH" ] || BEAMOS_NETCONNECTD_REPO_BRANCH=v1.0.0 [ -n "$BEAMOS_MRBEAMPLUGIN_DOCS_REPO_BRANCH" ] || BEAMOS_MRBEAMPLUGIN_DOCS_REPO_BRANCH=v1.1.0 ## BeamOS-dependencies @@ -25,7 +25,7 @@ TRUE_USER=pi [ -n "$BEAMOS_NETCONNECTD_WIFI_REPO_BRANCH" ] || BEAMOS_NETCONNECTD_WIFI_REPO_BRANCH=master # MrBeamPlugin -[ -n "$BEAMOS_INCLUDE_MRBEAMPLUGIN" ] || BEAMOS_INCLUDE_MRBEAMPLUGIN=yes +[ -n "$BEAMOS_INCLUDE_MRBEAMPLUGIN" ] || BEAMOS_INCLUDE_MRBEAMPLUGIN=no # This uses the latest release as an archive # [ -n "$BEAMOS_MRBEAMPLUGIN_ARCHIVE" ] || export BEAMOS_MRBEAMPLUGIN_ARCHIVE=$(wget -q -O - https://api.github.com/repos/mrbeam/MrBeamPlugin/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) [ -n "$BEAMOS_MRBEAMPLUGIN_ARCHIVE" ] || BEAMOS_MRBEAMPLUGIN_ARCHIVE=https://github.com/mrbeam/MrBeamPlugin/archive/$BEAMOS_MRBEAMPLUGIN_REPO_BRANCH.zip @@ -38,13 +38,13 @@ TRUE_USER=pi [ -n "$BEAMOS_MRBEAMPLUGIN_DOCS_REPO_BUILD" ] || BEAMOS_MRBEAMPLUGIN_DOCS_REPO_BUILD=https://github.com/mrbeam/MrBeamDoc.git # OctoPrint-Camera -[ -n "$BEAMOS_INCLUDE_CAMERA" ] || BEAMOS_INCLUDE_CAMERA=yes +[ -n "$BEAMOS_INCLUDE_CAMERA" ] || BEAMOS_INCLUDE_CAMERA=no [ -n "$BEAMOS_CAMERA_ARCHIVE" ] || BEAMOS_CAMERA_ARCHIVE=https://github.com/mrbeam/OctoPrint-Camera/archive/$BEAMOS_CAMERA_REPO_BRANCH.zip [ -n "$BEAMOS_CAMERA_REPO_BUILD" ] || BEAMOS_CAMERA_REPO_BUILD=https://github.com/mrbeam/OctoPrint-Camera.git [ -n "$BEAMOS_CAMERA_REPO_SHIP" ] || BEAMOS_CAMERA_REPO_SHIP=https://github.com/mrbeam/OctoPrint-Camera.git # IOBeam -[ -n "$BEAMOS_INCLUDE_IOBEAM" ] || BEAMOS_INCLUDE_IOBEAM=yes +[ -n "$BEAMOS_INCLUDE_IOBEAM" ] || BEAMOS_INCLUDE_IOBEAM=no [ -n "$BEAMOS_IOBEAM_ARCHIVE" ] || BEAMOS_IOBEAM_ARCHIVE=git+ssh://git@bitbucket.org/mrbeam/iobeam.git@$BEAMOS_IOBEAM_REPO_BRANCH [ -n "$BEAMOS_IOBEAM_REPO_BUILD" ] || BEAMOS_IOBEAM_REPO_BUILD=git+ssh://git@bitbucket.org/mrbeam/iobeam.git [ -n "$BEAMOS_IOBEAM_REPO_SHIP" ] || BEAMOS_IOBEAM_REPO_SHIP=git+ssh://git@bitbucket.org/mrbeam/iobeam.git @@ -53,13 +53,13 @@ TRUE_USER=pi [ -n "$BEAMOS_MRBHWINFO_REPO_SHIP" ] || BEAMOS_MRBHWINFO_REPO_SHIP=git+ssh://git@bitbucket.org/mrbeam/mrb_hw_info.git [ -n "$BEAMOS_INCLUDE_MRBEAMLED" ] || BEAMOS_INCLUDE_MRBEAMLED=yes -[ -n "$BEAMOS_MRBEAMLED_ARCHIVE" ] || BEAMOS_MRBEAMLED_ARCHIVE=https://github.com/mrbeam/MrBeamLedStrips/archive/$BEAMOS_MRBEAMLED_REPO_BRANCH.zip -[ -n "$BEAMOS_MRBEAMLED_REPO_BUILD" ] || BEAMOS_MRBEAMLED_REPO_BUILD=https://github.com/mrbeam/MrBeamLedStrips.git -[ -n "$BEAMOS_MRBEAMLED_REPO_SHIP" ] || BEAMOS_MRBEAMLED_REPO_SHIP=https://github.com/mrbeam/MrBeamLedStrips.git +[ -n "$BEAMOS_MRBEAMLED_ARCHIVE" ] || BEAMOS_MRBEAMLED_ARCHIVE=git+https://${PERSONAL_ACCESS_TOKEN}@github.com/mrbeam/mrb3-led-strips.git@$BEAMOS_MRBEAMLED_REPO_BRANCH +[ -n "$BEAMOS_MRBEAMLED_REPO_BUILD" ] || BEAMOS_MRBEAMLED_REPO_BUILD=https://github.com/mrbeam/mrb3-led-strips.git +[ -n "$BEAMOS_MRBEAMLED_REPO_SHIP" ] || BEAMOS_MRBEAMLED_REPO_SHIP=https://github.com/mrbeam/mrb3-led-strips.git [ -n "$BEAMOS_RPI_WS281X_ARCHIVE" ] || BEAMOS_RPI_WS281X_ARCHIVE=rpi-ws281x # Netconnectd and Netconnectd plugin -[ -n "$BEAMOS_INCLUDE_NETCONNECTD" ] || BEAMOS_INCLUDE_NETCONNECTD=yes +[ -n "$BEAMOS_INCLUDE_NETCONNECTD" ] || BEAMOS_INCLUDE_NETCONNECTD=no # Wifi package for netconnectd [ -n "$BEAMOS_NETCONNECTD_WIFI_ARCHIVE" ] || BEAMOS_NETCONNECTD_WIFI_ARCHIVE=https://github.com/mrbeam/wifi/archive/$BEAMOS_NETCONNECTD_WIFI_REPO_BRANCH.zip [ -n "$BEAMOS_NETCONNECTD_ARCHIVE" ] || BEAMOS_NETCONNECTD_ARCHIVE=https://github.com/mrbeam/netconnectd_mrbeam/archive/$BEAMOS_NETCONNECTD_REPO_BRANCH.zip @@ -71,27 +71,27 @@ TRUE_USER=pi [ -n "$BEAMOS_NETCONNECTD_PLUGIN_REPO_BUILD" ] || BEAMOS_NETCONNECTD_PLUGIN_REPO_BUILD=https://github.com/mrbeam/OctoPrint-Netconnectd.git [ -n "$BEAMOS_NETCONNECTD_PLUGIN_REPO_SHIP" ] || BEAMOS_NETCONNECTD_PLUGIN_REPO_SHIP=https://github.com/mrbeam/OctoPrint-Netconnectd.git -[ -n "$BEAMOS_INCLUDE_FINDMYMRBEAM" ] || BEAMOS_INCLUDE_FINDMYMRBEAM=yes +[ -n "$BEAMOS_INCLUDE_FINDMYMRBEAM" ] || BEAMOS_INCLUDE_FINDMYMRBEAM=no [ -n "$BEAMOS_FINDMYMRBEAM_ARCHIVE" ] || BEAMOS_FINDMYMRBEAM_ARCHIVE=https://github.com/mrbeam/OctoPrint-FindMyMrBeam/archive/$BEAMOS_FINDMYMRBEAM_REPO_BRANCH.zip [ -n "$BEAMOS_FINDMYMRBEAM_REPO_BUILD" ] || BEAMOS_FINDMYMRBEAM_REPO_BUILD=https://github.com/mrbeam/OctoPrint-FindMyMrBeam.git [ -n "$BEAMOS_FINDMYMRBEAM_REPO_SHIP" ] || BEAMOS_FINDMYMRBEAM_REPO_SHIP=https://github.com/mrbeam/OctoPrint-FindMyMrBeam.git -[ -n "$BEAMOS_INCLUDE_SHIELDFLASHER" ] || BEAMOS_INCLUDE_SHIELDFLASHER=yes +[ -n "$BEAMOS_INCLUDE_SHIELDFLASHER" ] || BEAMOS_INCLUDE_SHIELDFLASHER=no [ -n "$BEAMOS_SHIELDFLASHER_ARCHIVE" ] || BEAMOS_SHIELDFLASHER_ARCHIVE=https://github.com/mrbeam/shield_flasher/archive/$BEAMOS_SHIELDFLASHER_REPO_BRANCH.zip [ -n "$BEAMOS_SHIELDFLASHER_REPO_BUILD" ] || BEAMOS_SHIELDFLASHER_REPO_BUILD=https://github.com/mrbeam/shield_flasher.git [ -n "$BEAMOS_SHIELDFLASHER_REPO_SHIP" ] || BEAMOS_SHIELDFLASHER_REPO_SHIP=https://github.com/mrbeam/shield_flasher.git -[ -n "$BEAMOS_INCLUDE_MOUNTMANAGER" ] || BEAMOS_INCLUDE_MOUNTMANAGER=yes +[ -n "$BEAMOS_INCLUDE_MOUNTMANAGER" ] || BEAMOS_INCLUDE_MOUNTMANAGER=no [ -n "$BEAMOS_MOUNTMANAGER_ARCHIVE" ] || BEAMOS_MOUNTMANAGER_ARCHIVE=https://github.com/mrbeam/usb_mount_manager/archive/$BEAMOS_MOUNTMANAGER_REPO_BRANCH.zip [ -n "$BEAMOS_MOUNTMANAGER_REPO_BUILD" ] || BEAMOS_MOUNTMANAGER_REPO_BUILD=git+ssh://git@bitbucket.org/mrbeam/usb_mount_manager.git [ -n "$BEAMOS_MOUNTMANAGER_REPO_SHIP" ] || BEAMOS_MOUNTMANAGER_REPO_SHIP=git+ssh://git@bitbucket.org/mrbeam/usb_mount_manager.git -[ -n "$BEAMOS_INCLUDE_CHECK" ] || BEAMOS_INCLUDE_CHECK=yes +[ -n "$BEAMOS_INCLUDE_CHECK" ] || BEAMOS_INCLUDE_CHECK=no [ -n "$BEAMOS_CHECK_ARCHIVE" ] || BEAMOS_CHECK_ARCHIVE=https://github.com/mrbeam/mrb_check/archive/$BEAMOS_CHECK_REPO_BRANCH.zip [ -n "$BEAMOS_CHECK_REPO_BUILD" ] || BEAMOS_CHECK_REPO_BUILD=git+ssh://git@github.com:mrbeam/mrb_check.git [ -n "$BEAMOS_CHECK_REPO_SHIP" ] || BEAMOS_CHECK_REPO_SHIP=git+ssh://git@github.com:mrbeam/mrb_check.git ### Misc -[ -n "$BEAMOS_DEV" ] || BEAMOS_DEV=yes +[ -n "$BEAMOS_DEV" ] || BEAMOS_DEV=no [ -n "$BEAMOS_I2C_BAUDRATE" ] || BEAMOS_I2C_BAUDRATE=64000 [ -n "$BEAMOS_MODEL" ] || BEAMOS_MODEL=MRBEAM2_DC_S diff --git a/src/modules/beamos/filesystem/analytics/root/etc/logrotate.d/analytics b/src/modules/beamos/filesystem/analytics/root/etc/logrotate.d/analytics deleted file mode 100644 index c0728c66..00000000 --- a/src/modules/beamos/filesystem/analytics/root/etc/logrotate.d/analytics +++ /dev/null @@ -1,13 +0,0 @@ -# rotated files won't get uploaded. But rotation is a kind of safetynet to avoid analysis file from growing indefinitely -# in case the upload never happens - -/home/pi/.octoprint/analytics/analytics_log.json { - size 100M - rotate 3 - compress - delaycompress - missingok - notifempty - dateext - dateformat .%Y-%m-%d -} diff --git a/src/modules/beamos/filesystem/home/pi/.bash_history b/src/modules/beamos/filesystem/home/pi/.bash_history deleted file mode 100644 index 29ad8e23..00000000 --- a/src/modules/beamos/filesystem/home/pi/.bash_history +++ /dev/null @@ -1,37 +0,0 @@ -mrbeam_ledstrips_cli flash_white -mrbeam_ledstrips_cli -i2cset 0x2a 0x81 0x64 # Exhaust 100% -i2cset 0x2a 0x81 0x00 # Exhaust off -i2cset 0x2c 0x82 0x64 # Compressor 200 mbar -i2cset 0x2c 0x82 0x00 # Compressor off -i2cset 0x2c 0x87 0x64 # Ozon 100 PPM -i2cset 0x2c 0x87 0x00 # Ozon off -i2cdetect -netconnectcli status -tail -f -n200 /var/log/mount_manager.log -tail -f -n200 /var/log/netconnectd.log -tail -f -n200 /var/log/mrbeam_ledstrips.log -tail -f -n200 /var/log/iobeam.log -tail -f -n200 /var/log/mrb_check.log -tail -f -n200 ~/.octoprint/logs/octoprint.log -workon oprint -sudo shutdown now -sudo reboot -systemctl restart netconnectd # pi user has permission to use systemd -systemctl restart mrbeam_ledstrips # pi user has permission to use systemd -systemctl restart iobeam # pi user has permission to use systemd -systemctl restart octoprint # pi user has permission to use systemd -systemctl status octoprint # pi user has permission to use systemd -restart_iobeam -restart_mrbeam_ledstrips -restart_netconnectd -restart_octoprint -iobeamcli info -iobeamcli fan -c off -iobeamcli fan -c on 100 -iobeamcli -sudo nano /etc/mrbeam # uses micro, use Ctrl + q to quit, Ctrl + g for shortcut list -sudo nano ~/.octoprint/config.yaml # uses micro, use Ctrl + q to quit, Ctrl + g for shortcut list -nano /etc/mrbeam # uses micro, use Ctrl + q to quit, Ctrl + g for shortcut list -nano ~/.octoprint/config.yaml # uses micro, use Ctrl + q to quit, Ctrl + g for shortcut list -yq e ~/.octoprint/config.yaml # inspect config.yaml diff --git a/src/modules/beamos/filesystem/home/pi/.bashrc b/src/modules/beamos/filesystem/home/pi/.bashrc deleted file mode 100644 index dc9ba7b2..00000000 --- a/src/modules/beamos/filesystem/home/pi/.bashrc +++ /dev/null @@ -1,79 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - -# Run this when starting a shell -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# If set, the pattern "**" used in a pathname expansion context will -# match all files and zero or more directories and subdirectories. -#shopt -s globstar - -# make less more friendly for non-text input files, see lesspipe(1) -#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - - -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt force_color_prompt - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -if ! shopt -oq posix; then - if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - fi -fi - -# suse style shell history browsing -bind '"\e[A"':history-search-backward -bind '"\e[B"':history-search-forward - -# Run the cross-shell behaviour -[ -f ~/.config/shellrc ] && . ~/.config/shellrc diff --git a/src/modules/beamos/filesystem/home/pi/.config/aliases b/src/modules/beamos/filesystem/home/pi/.config/aliases deleted file mode 100644 index 22c16f92..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/aliases +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -# Common aliases -alias ..="cd .." -alias ...="cd ../.." -alias ll="ls -l" -alias l="ls -al" - -# Systemd aliases -alias restart_octoprint='sudo systemctl restart octoprint.service' -alias restart_iobeam='sudo systemctl restart iobeam.service' -alias restart_mrbeam_ledstrips='sudo systemctl restart mrbeam_ledstrips.service' -alias restart_netconnectd='sudo systemctl restart netconnectd.service' - -alias stop_octoprint='sudo systemctl stop octoprint.service' -alias stop_iobeam='sudo systemctl stop iobeam.service' -alias stop_mrbeam_ledstrips='sudo systemctl stop mrbeam_ledstrips.service' -alias stop_netconnectd='sudo systemctl stop netconnectd.service' -alias nano="micro" - -alias kill_octoprint='killall -9 /home/pi/oprint/bin/python2' - -# Seems to return bash errors. -# # use i2c bus 1 by default -# -# i2cdetect() { -# if [ $1 = "-y" ]; then -# bus=$2 -# shift 2 -# else -# bus=1 -# fi -# i2cdetect -y $bus $@ -# } -# i2cset() { -# if [ $1 = "-y" ]; then -# bus=$2 -# shift 2 -# else -# bus=1 -# fi -# i2cset -y $bus $@ -# } - -workon() { - help() { echo "Usage: $0 [-h, --help] venv-name" && echo "Activates a Python venv located in HOME or give path"; } - [ -z "$1" ] && help && return 1 - { [ "$1" = "-h" ] || [ "$1" = "--help" ];} && help && return 0 - if [ -f "$1/bin/activate" ]; then - . "$1/bin/activate" - else - . "$HOME/$1/bin/activate" - fi -} diff --git a/src/modules/beamos/filesystem/home/pi/.config/disclaimer b/src/modules/beamos/filesystem/home/pi/.config/disclaimer deleted file mode 100644 index 425bef26..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/disclaimer +++ /dev/null @@ -1 +0,0 @@ -You have accessed a restricted system of the Mr Beam. If you chose to continue, Mr Beam Lasers GmbH will not support any claims and is not obligated to fullfil any warranty. diff --git a/src/modules/beamos/filesystem/home/pi/.config/htop/htoprc b/src/modules/beamos/filesystem/home/pi/.config/htop/htoprc deleted file mode 100644 index 28f358c2..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/htop/htoprc +++ /dev/null @@ -1,25 +0,0 @@ -# Beware! This file is rewritten by htop when settings are changed in the interface. -# The parser is also very primitive, and not human-friendly. -fields=0 48 17 18 38 39 40 2 46 47 49 1 -sort_key=49 -sort_direction=1 -hide_threads=0 -hide_kernel_threads=1 -hide_userland_threads=0 -shadow_other_users=0 -show_thread_names=1 -highlight_base_name=0 -highlight_megabytes=1 -highlight_threads=0 -tree_view=1 -header_margin=1 -detailed_cpu_time=0 -cpu_count_from_zero=0 -update_process_names=0 -account_guest_in_cpu_meter=0 -color_scheme=0 -delay=15 -left_meters=AllCPUs Memory Swap -left_meter_modes=1 1 1 -right_meters=Tasks LoadAverage Uptime -right_meter_modes=2 2 2 diff --git a/src/modules/beamos/filesystem/home/pi/.config/logo_ascii b/src/modules/beamos/filesystem/home/pi/.config/logo_ascii deleted file mode 100644 index 31b0a66f..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/logo_ascii +++ /dev/null @@ -1,12 +0,0 @@ - -.:**************. .**************:. - "mm "mrbeamm" mm" - "m. *mm*mm* .m" - m* .mm" "mm. *m - "m. .mm mm. .m" - *********** *********** - - .*mm*. .*mm*. - .mrbeam*mrbeam. - *m**mrbeam* *mrbeam**m* - "**mm**" "**mm**" diff --git a/src/modules/beamos/filesystem/home/pi/.config/neofetch/config.conf b/src/modules/beamos/filesystem/home/pi/.config/neofetch/config.conf deleted file mode 100644 index f4282283..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/neofetch/config.conf +++ /dev/null @@ -1,787 +0,0 @@ -# See this wiki page for more info: -# https://github.com/dylanaraps/neofetch/wiki/Customizing-Info - -sysd_status() { - systemctl show -qp SubState $@ | cut -f2 -d"="; -} - -device_info() { - ret="$(grep $1 /etc/mrbeam | cut -f2 --delimiter='=')" - if [ -z $ret ]; then - echo "" - else - echo $ret - fi -} - -beamos_version() { - echo "$(cat /etc/beamos_version)" -} - -print_info() { - info title - info underline - - info "OS" distro - prin "Serial Number" "$(device_info serial)" - prin "Beam OS Identifier" "$(device_info octopi)" - prin "Beam OS version" $(beamos_version) - info "Host" model - info "Local IP" local_ip - info "Packages" packages - info "Memory" memory - prin "--Systemd status--" - prin "OctoPrint" $(sysd_status octoprint) - prin "LED Strips" $(sysd_status mrbeam_ledstrips) - prin "IO Beam" $(sysd_status iobeam) - prin "Netconnectd" $(sysd_status netconnectd) - - #info "Resolution" resolution - #info "DE" de - #info "WM" wm - #info "WM Theme" wm_theme - #info "Theme" theme - #info "Icons" icons - #info "Terminal" term - #info "Terminal Font" term_font - #info "CPU" cpu - #info "GPU" gpu - # info "Kernel" kernel - # info "Shell" shell - # info "Uptime" uptime - # info "GPU Driver" gpu_driver # Linux/macOS only - # info "CPU Usage" cpu_usage - # info "Disk" disk - # info "Battery" battery - # info "Font" font - # info "Song" song - # [[ $player ]] && prin "Music Player" "$player" - # info "Public IP" public_ip - # info "Users" users - # info "Locale" locale # This only works on glibc systems. - - # info cols # Terminal colors -} - - -# Kernel - - -# Shorten the output of the kernel function. -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --kernel_shorthand -# Supports: Everything except *BSDs (except PacBSD and PC-BSD) -# -# Example: -# on: '4.8.9-1-ARCH' -# off: 'Linux 4.8.9-1-ARCH' -kernel_shorthand="on" - - -# Distro - - -# Shorten the output of the distro function -# -# Default: 'off' -# Values: 'on', 'off', 'tiny' -# Flag: --distro_shorthand -# Supports: Everything except Windows and Haiku -distro_shorthand="off" - -# Show/Hide OS Architecture. -# Show 'x86_64', 'x86' and etc in 'Distro:' output. -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --os_arch -# -# Example: -# on: 'Arch Linux x86_64' -# off: 'Arch Linux' -os_arch="on" - - -# Uptime - - -# Shorten the output of the uptime function -# -# Default: 'on' -# Values: 'on', 'off', 'tiny' -# Flag: --uptime_shorthand -# -# Example: -# on: '2 days, 10 hours, 3 mins' -# off: '2 days, 10 hours, 3 minutes' -# tiny: '2d 10h 3m' -uptime_shorthand="on" - - -# Memory - - -# Show memory pecentage in output. -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --memory_percent -# -# Example: -# on: '1801MiB / 7881MiB (22%)' -# off: '1801MiB / 7881MiB' -memory_percent="off" - - -# Packages - - -# Show/Hide Package Manager names. -# -# Default: 'tiny' -# Values: 'on', 'tiny' 'off' -# Flag: --package_managers -# -# Example: -# on: '998 (pacman), 8 (flatpak), 4 (snap)' -# tiny: '908 (pacman, flatpak, snap)' -# off: '908' -package_managers="on" - - -# Shell - - -# Show the path to $SHELL -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --shell_path -# -# Example: -# on: '/bin/bash' -# off: 'bash' -shell_path="off" - -# Show $SHELL version -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --shell_version -# -# Example: -# on: 'bash 4.4.5' -# off: 'bash' -shell_version="on" - - -# CPU - - -# CPU speed type -# -# Default: 'bios_limit' -# Values: 'scaling_cur_freq', 'scaling_min_freq', 'scaling_max_freq', 'bios_limit'. -# Flag: --speed_type -# Supports: Linux with 'cpufreq' -# NOTE: Any file in '/sys/devices/system/cpu/cpu0/cpufreq' can be used as a value. -speed_type="bios_limit" - -# CPU speed shorthand -# -# Default: 'off' -# Values: 'on', 'off'. -# Flag: --speed_shorthand -# NOTE: This flag is not supported in systems with CPU speed less than 1 GHz -# -# Example: -# on: 'i7-6500U (4) @ 3.1GHz' -# off: 'i7-6500U (4) @ 3.100GHz' -speed_shorthand="off" - -# Enable/Disable CPU brand in output. -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --cpu_brand -# -# Example: -# on: 'Intel i7-6500U' -# off: 'i7-6500U (4)' -cpu_brand="on" - -# CPU Speed -# Hide/Show CPU speed. -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --cpu_speed -# -# Example: -# on: 'Intel i7-6500U (4) @ 3.1GHz' -# off: 'Intel i7-6500U (4)' -cpu_speed="on" - -# CPU Cores -# Display CPU cores in output -# -# Default: 'logical' -# Values: 'logical', 'physical', 'off' -# Flag: --cpu_cores -# Support: 'physical' doesn't work on BSD. -# -# Example: -# logical: 'Intel i7-6500U (4) @ 3.1GHz' (All virtual cores) -# physical: 'Intel i7-6500U (2) @ 3.1GHz' (All physical cores) -# off: 'Intel i7-6500U @ 3.1GHz' -cpu_cores="logical" - -# CPU Temperature -# Hide/Show CPU temperature. -# Note the temperature is added to the regular CPU function. -# -# Default: 'off' -# Values: 'C', 'F', 'off' -# Flag: --cpu_temp -# Supports: Linux, BSD -# NOTE: For FreeBSD and NetBSD-based systems, you'll need to enable -# coretemp kernel module. This only supports newer Intel processors. -# -# Example: -# C: 'Intel i7-6500U (4) @ 3.1GHz [27.2°C]' -# F: 'Intel i7-6500U (4) @ 3.1GHz [82.0°F]' -# off: 'Intel i7-6500U (4) @ 3.1GHz' -cpu_temp="off" - - -# GPU - - -# Enable/Disable GPU Brand -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --gpu_brand -# -# Example: -# on: 'AMD HD 7950' -# off: 'HD 7950' -gpu_brand="on" - -# Which GPU to display -# -# Default: 'all' -# Values: 'all', 'dedicated', 'integrated' -# Flag: --gpu_type -# Supports: Linux -# -# Example: -# all: -# GPU1: AMD HD 7950 -# GPU2: Intel Integrated Graphics -# -# dedicated: -# GPU1: AMD HD 7950 -# -# integrated: -# GPU1: Intel Integrated Graphics -gpu_type="all" - - -# Resolution - - -# Display refresh rate next to each monitor -# Default: 'off' -# Values: 'on', 'off' -# Flag: --refresh_rate -# Supports: Doesn't work on Windows. -# -# Example: -# on: '1920x1080 @ 60Hz' -# off: '1920x1080' -refresh_rate="off" - - -# Gtk Theme / Icons / Font - - -# Shorten output of GTK Theme / Icons / Font -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --gtk_shorthand -# -# Example: -# on: 'Numix, Adwaita' -# off: 'Numix [GTK2], Adwaita [GTK3]' -gtk_shorthand="off" - - -# Enable/Disable gtk2 Theme / Icons / Font -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --gtk2 -# -# Example: -# on: 'Numix [GTK2], Adwaita [GTK3]' -# off: 'Adwaita [GTK3]' -gtk2="on" - -# Enable/Disable gtk3 Theme / Icons / Font -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --gtk3 -# -# Example: -# on: 'Numix [GTK2], Adwaita [GTK3]' -# off: 'Numix [GTK2]' -gtk3="on" - - -# IP Address - - -# Website to ping for the public IP -# -# Default: 'http://ident.me' -# Values: 'url' -# Flag: --ip_host -public_ip_host="http://ident.me" - -# Public IP timeout. -# -# Default: '2' -# Values: 'int' -# Flag: --ip_timeout -public_ip_timeout=2 - - -# Disk - - -# Which disks to display. -# The values can be any /dev/sdXX, mount point or directory. -# NOTE: By default we only show the disk info for '/'. -# -# Default: '/' -# Values: '/', '/dev/sdXX', '/path/to/drive'. -# Flag: --disk_show -# -# Example: -# disk_show=('/' '/dev/sdb1'): -# 'Disk (/): 74G / 118G (66%)' -# 'Disk (/mnt/Videos): 823G / 893G (93%)' -# -# disk_show=('/'): -# 'Disk (/): 74G / 118G (66%)' -# -disk_show=('/') - -# Disk subtitle. -# What to append to the Disk subtitle. -# -# Default: 'mount' -# Values: 'mount', 'name', 'dir' -# Flag: --disk_subtitle -# -# Example: -# name: 'Disk (/dev/sda1): 74G / 118G (66%)' -# 'Disk (/dev/sdb2): 74G / 118G (66%)' -# -# mount: 'Disk (/): 74G / 118G (66%)' -# 'Disk (/mnt/Local Disk): 74G / 118G (66%)' -# 'Disk (/mnt/Videos): 74G / 118G (66%)' -# -# dir: 'Disk (/): 74G / 118G (66%)' -# 'Disk (Local Disk): 74G / 118G (66%)' -# 'Disk (Videos): 74G / 118G (66%)' -disk_subtitle="mount" - - -# Song - - -# Manually specify a music player. -# -# Default: 'auto' -# Values: 'auto', 'player-name' -# Flag: --music_player -# -# Available values for 'player-name': -# -# amarok -# audacious -# banshee -# bluemindo -# clementine -# cmus -# deadbeef -# deepin-music -# dragon -# elisa -# exaile -# gnome-music -# gmusicbrowser -# guayadeque -# iTunes -# juk -# lollypop -# mocp -# mopidy -# mpd -# netease-cloud-music -# pogo -# pragha -# qmmp -# quodlibet -# rhythmbox -# sayonara -# smplayer -# spotify -# tomahawk -# vlc -# xmms2d -# yarock -music_player="auto" - -# Format to display song information. -# -# Default: '%artist% - %album% - %title%' -# Values: '%artist%', '%album%', '%title%' -# Flag: --song_format -# -# Example: -# default: 'Song: Jet - Get Born - Sgt Major' -song_format="%artist% - %album% - %title%" - -# Print the Artist, Album and Title on separate lines -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --song_shorthand -# -# Example: -# on: 'Artist: The Fratellis' -# 'Album: Costello Music' -# 'Song: Chelsea Dagger' -# -# off: 'Song: The Fratellis - Costello Music - Chelsea Dagger' -song_shorthand="off" - -# 'mpc' arguments (specify a host, password etc). -# -# Default: '' -# Example: mpc_args=(-h HOST -P PASSWORD) -mpc_args=() - - -# Text Colors - - -# Text Colors -# -# Default: 'distro' -# Values: 'distro', 'num' 'num' 'num' 'num' 'num' 'num' -# Flag: --colors -# -# Each number represents a different part of the text in -# this order: 'title', '@', 'underline', 'subtitle', 'colon', 'info' -# -# Example: -# colors=(distro) - Text is colored based on Distro colors. -# colors=(4 6 1 8 8 6) - Text is colored in the order above. -colors=(distro) - - -# Text Options - - -# Toggle bold text -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --bold -bold="on" - -# Enable/Disable Underline -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --underline -underline_enabled="on" - -# Underline character -# -# Default: '-' -# Values: 'string' -# Flag: --underline_char -underline_char="-" - - -# Info Separator -# Replace the default separator with the specified string. -# -# Default: ':' -# Flag: --separator -# -# Example: -# separator="->": 'Shell-> bash' -# separator=" =": 'WM = dwm' -separator=":" - - -# Color Blocks - - -# Color block range -# The range of colors to print. -# -# Default: '0', '7' -# Values: 'num' -# Flag: --block_range -# -# Example: -# -# Display colors 0-7 in the blocks. (8 colors) -# neofetch --block_range 0 7 -# -# Display colors 0-15 in the blocks. (16 colors) -# neofetch --block_range 0 15 -block_range=(0 7) - -# Toggle color blocks -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --color_blocks -color_blocks="on" - -# Color block width in spaces -# -# Default: '3' -# Values: 'num' -# Flag: --block_width -block_width=3 - -# Color block height in lines -# -# Default: '1' -# Values: 'num' -# Flag: --block_height -block_height=1 - - -# Progress Bars - - -# Bar characters -# -# Default: '-', '=' -# Values: 'string', 'string' -# Flag: --bar_char -# -# Example: -# neofetch --bar_char 'elapsed' 'total' -# neofetch --bar_char '-' '=' -bar_char_elapsed="-" -bar_char_total="=" - -# Toggle Bar border -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --bar_border -bar_border="on" - -# Progress bar length in spaces -# Number of chars long to make the progress bars. -# -# Default: '15' -# Values: 'num' -# Flag: --bar_length -bar_length=15 - -# Progress bar colors -# When set to distro, uses your distro's logo colors. -# -# Default: 'distro', 'distro' -# Values: 'distro', 'num' -# Flag: --bar_colors -# -# Example: -# neofetch --bar_colors 3 4 -# neofetch --bar_colors distro 5 -bar_color_elapsed="distro" -bar_color_total="distro" - - -# Info display -# Display a bar with the info. -# -# Default: 'off' -# Values: 'bar', 'infobar', 'barinfo', 'off' -# Flags: --cpu_display -# --memory_display -# --battery_display -# --disk_display -# -# Example: -# bar: '[---=======]' -# infobar: 'info [---=======]' -# barinfo: '[---=======] info' -# off: 'info' -cpu_display="off" -memory_display="off" -battery_display="off" -disk_display="off" - - -# Backend Settings - - -# Image backend. -# -# Default: 'ascii' -# Values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2', 'off', -# 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty' -# Flag: --backend -image_backend="ascii" - -# Image Source -# -# Which image or ascii file to display. -# -# Default: 'auto' -# Values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/' -# 'command output (neofetch --ascii "$(fortune | cowsay -W 30)")' -# Flag: --source -# -# NOTE: 'auto' will pick the best image source for whatever image backend is used. -# In ascii mode, distro ascii art will be used and in an image mode, your -# wallpaper will be used. -image_source='auto' - - -# Ascii Options - - -# Ascii distro -# Which distro's ascii art to display. -# -# Default: 'auto' -# Values: 'auto', 'distro_name' -# Flag: --ascii_distro -# -# NOTE: Arch and Ubuntu have 'old' logo variants. -# Change this to 'arch_old' or 'ubuntu_old' to use the old logos. -# NOTE: Ubuntu has flavor variants. -# Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME' or 'Ubuntu-Budgie' to use the flavors. -# NOTE: Arch, Crux and Gentoo have a smaller logo variant. -# Change this to 'arch_small', 'crux_small' or 'gentoo_small' to use the small logos. -ascii_distro="auto" - -# Ascii Colors -# -# Default: 'distro' -# Values: 'distro', 'num' 'num' 'num' 'num' 'num' 'num' -# Flag: --ascii_colors -# -# Example: -# ascii_colors=(distro) - Ascii is colored based on Distro colors. -# ascii_colors=(4 6 1 8 8 6) - Ascii is colored using these colors. -ascii_colors=(distro) - -# Bold ascii logo -# Whether or not to bold the ascii logo. -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --ascii_bold -ascii_bold="on" - - -# Image Options - - -# Image loop -# Setting this to on will make neofetch redraw the image constantly until -# Ctrl+C is pressed. This fixes display issues in some terminal emulators. -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --loop -image_loop="off" - -# Thumbnail directory -# -# Default: '~/.cache/thumbnails/neofetch' -# Values: 'dir' -thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch" - -# Crop mode -# -# Default: 'normal' -# Values: 'normal', 'fit', 'fill' -# Flag: --crop_mode -# -# See this wiki page to learn about the fit and fill options. -# https://github.com/dylanaraps/neofetch/wiki/What-is-Waifu-Crop%3F -crop_mode="normal" - -# Crop offset -# Note: Only affects 'normal' crop mode. -# -# Default: 'center' -# Values: 'northwest', 'north', 'northeast', 'west', 'center' -# 'east', 'southwest', 'south', 'southeast' -# Flag: --crop_offset -crop_offset="center" - -# Image size -# The image is half the terminal width by default. -# -# Default: 'auto' -# Values: 'auto', '00px', '00%', 'none' -# Flags: --image_size -# --size -image_size="auto" - -# Gap between image and text -# -# Default: '3' -# Values: 'num', '-num' -# Flag: --gap -gap=3 - -# Image offsets -# Only works with the w3m backend. -# -# Default: '0' -# Values: 'px' -# Flags: --xoffset -# --yoffset -yoffset=0 -xoffset=0 - -# Image background color -# Only works with the w3m backend. -# -# Default: '' -# Values: 'color', 'blue' -# Flag: --bg_color -background_color= - - -# Misc Options - -# Stdout mode -# Turn off all colors and disables image backend (ASCII/Image). -# Useful for piping into another command. -# Default: 'off' -# Values: 'on', 'off' -stdout="off" diff --git a/src/modules/beamos/filesystem/home/pi/.config/shellrc b/src/modules/beamos/filesystem/home/pi/.config/shellrc deleted file mode 100644 index 47aeded3..00000000 --- a/src/modules/beamos/filesystem/home/pi/.config/shellrc +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/sh -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - alias dir='dir --color=auto' - alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# Alias definitions. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. -if [ -f ~/.config/aliases ]; then - . ~/.config/aliases -fi - -## git -parse_git_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' -} - -# Extend PATH -export PATH="$HOME/.local/bin:$PATH" - -# prompt - -RED="\[\033[0;31m\]" -YELLOW="\[\033[0;33m\]" -GREEN="\[\033[0;32m\]" -NO_COLOUR="\[\033[0m\]" - -PS1="$GREEN\u@\h$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\> " - -# Show some fun(ctional) stuff when opening a shell -## Banner -figlet -cf slant BeamOS 2>/dev/null || echo "Welcome to beamOS!" -## Disclaimer in Red -{ { [ -f ~/.disclaimer ] && disc="$HOME/.disclaimer";} || { [ -f ~/.config/disclaimer ] && disc="$HOME/.config/disclaimer";};} && \ - printf "\033[0;31m" && cat "$disc" && printf "\033[0;0m" -# Show detailed info about the systemd status of these services -#systemctl --no-pager status -n 0 mrbeam_ledstrips netconnectd iobeam octoprint - -# nice neofetch greeting - a bit slow though -echo # Extra newline for stylezz -neofetch --ascii "$(cat /home/pi/.config/logo_ascii)" 2>/dev/null diff --git a/src/modules/beamos/filesystem/home/pi/.hushlogin b/src/modules/beamos/filesystem/home/pi/.hushlogin deleted file mode 100644 index e69de29b..00000000 diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml b/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml deleted file mode 100644 index dcf37352..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml +++ /dev/null @@ -1,31 +0,0 @@ -webcam: - stream: plugin/mrbeam/static/img/test.jpg -plugins: - discovery: - publicPort: 80 - mrbeam: - dev: - env: PROD - software_tier: PROD - netconnectd: - socket: /var/run/netconnectd.sock - softwareupdate: - checks: - octoprint: - pip: https://github.com/mrbeam/OctoPrint/archive/{target_version}.zip - user: mrbeam -serial: - additionalPorts: - - /dev/ttyAMA* - autoconnect: true - baudrate: 115200 - port: /dev/ttyAMA0 -server: - commands: - serverRestartCommand: sudo systemctl restart octoprint.service - systemRestartCommand: sudo shutdown -r now - systemShutdownCommand: sudo shutdown -h now - onlineCheck: - enabled: true - host: find.mr-beam.org - port: '80' diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml.dev b/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml.dev deleted file mode 100644 index 5d1eef9a..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/config.yaml.dev +++ /dev/null @@ -1,20 +0,0 @@ -accessControl: - salt: 2Ajc3zpiF780TsPGa7bElcwy41Ml0y5c -devel: - analyticsEnabled: false - cache: - enabled: false - webassets: - bundle: false - clean_on_startup: true - minify: false -plugins: - mrbeam: - dev: - env: DEV - software_tier: DEV - terminal: true -server: - firstRun: false - seenWizards: - mrbeam: 19 diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Focus_Lehre.svg b/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Focus_Lehre.svg deleted file mode 100644 index 5db47c63..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Focus_Lehre.svg +++ /dev/null @@ -1,467 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam.svg b/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam.svg deleted file mode 100644 index 1e2e926b..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam.svg +++ /dev/null @@ -1,26 +0,0 @@ - -image/svg+xml \ No newline at end of file diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam_Logo.svg b/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam_Logo.svg deleted file mode 100644 index dc2c42cd..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/MrBeam_Logo.svg +++ /dev/null @@ -1,38 +0,0 @@ - -image/svg+xml \ No newline at end of file diff --git "a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Schlu\314\210sselanha\314\210nger.svg" "b/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Schlu\314\210sselanha\314\210nger.svg" deleted file mode 100644 index 68f7838e..00000000 --- "a/src/modules/beamos/filesystem/home/pi/.octoprint/uploads/Schlu\314\210sselanha\314\210nger.svg" +++ /dev/null @@ -1,48 +0,0 @@ - -image/svg+xml \ No newline at end of file diff --git a/src/modules/beamos/filesystem/home/pi/.octoprint/users-dev.yaml b/src/modules/beamos/filesystem/home/pi/.octoprint/users-dev.yaml deleted file mode 100644 index 42eac0ef..00000000 --- a/src/modules/beamos/filesystem/home/pi/.octoprint/users-dev.yaml +++ /dev/null @@ -1,19 +0,0 @@ -dev@mr-beam.org: - active: true - apikey: null - password: e07e596d4a958ec6c957bbcd25a4c1088435d37a941d825c0bcfb51ab89a7ec0b8f08115587985969dd4af4c5e4c05bf5c33bc059fcc419015aa5f8b1124c387 - roles: - - user - - admin - settings: - mrbeam: - design_store_email: dev@mr-beam.org - lasersafety: - sent_to_cloud: 1616676592.602827 - show_again: false - messages: - lastId: 1 - unreadIds: - - 1 - ts: 1616676592.686951 - version: 0.8.1.1 diff --git a/src/modules/beamos/filesystem/home/pi/scripts/fake-hwclock_cron_job b/src/modules/beamos/filesystem/home/pi/scripts/fake-hwclock_cron_job deleted file mode 100644 index 8a8038bd..00000000 --- a/src/modules/beamos/filesystem/home/pi/scripts/fake-hwclock_cron_job +++ /dev/null @@ -1 +0,0 @@ -*/5 * * * * /sbin/fake-hwclock save diff --git a/src/modules/beamos/filesystem/home/pi/scripts/reset_script.sh b/src/modules/beamos/filesystem/home/pi/scripts/reset_script.sh deleted file mode 100755 index 9d251d02..00000000 --- a/src/modules/beamos/filesystem/home/pi/scripts/reset_script.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# in case of an error, flash red -trap signal_err ERR - -signal_err() { - mrbeam_ledstrips_cli flash_red - sleep 1 - mrbeam_ledstrips_cli red - exit 1 -} - -siganl_ok() { - mrbeam_ledstrips_cli flash_green - sleep 1 - mrbeam_ledstrips_cli green -} - -sudo systemctl stop octoprint.service - -pushd /home/pi/.octoprint - # Cleanup entries in the config.yaml - sed -i '/firstRun:/d' config.yaml - sed -i '/secretKey:/d' config.yaml - sed -i '/upnpUuid:/d' config.yaml - sed -i '/seenWizards:/,+1d' config.yaml - sed -i '/api:/,+1d' config.yaml - sed -i '/accessControl:/,+1d' config.yaml - - # Delete users.yaml - rm -f users.yaml - - pushd uploads - # Cleanup the uploads dir (delete all files but the listed) - find . -maxdepth 1 -type f \ - -not -name 'Focus_Lehre*.svg' \ - -not -name 'MrBeam.svg' \ - -not -name 'MrBeam_Logo.svg' \ - -not -name 'Schlusselanhanger.svg' \ - -delete - - rm cam/* - rm local/* - popd -popd - -pushd /etc/network/ - # Delete configured Wifi - sudo sed -i '/wlan0-netconnectd_wifi/,+3d' interfaces -popd - -# flash green -siganl_ok - - diff --git a/src/modules/beamos/filesystem/iobeam/root/etc/logrotate.d/iobeam b/src/modules/beamos/filesystem/iobeam/root/etc/logrotate.d/iobeam deleted file mode 100644 index d02feb87..00000000 --- a/src/modules/beamos/filesystem/iobeam/root/etc/logrotate.d/iobeam +++ /dev/null @@ -1,11 +0,0 @@ -/var/log/iobeam.log { - size 2M - rotate 3 - compress - delaycompress - missingok - notifempty - copytruncate - dateext - dateformat .%Y-%m-%d -} diff --git a/src/modules/beamos/filesystem/iobeam/root/etc/systemd/system/iobeam.service b/src/modules/beamos/filesystem/iobeam/root/etc/systemd/system/iobeam.service deleted file mode 100644 index f635e081..00000000 --- a/src/modules/beamos/filesystem/iobeam/root/etc/systemd/system/iobeam.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Mr Beam II iobeam Daemon -After=socket.target - -[Service] -Type=idle -ExecStart=/usr/local/iobeam/venv/bin/iobeam -PIDFile=/var/run/iobeam.pid - -[Install] -WantedBy=multi-user.target diff --git a/src/modules/beamos/filesystem/known_hosts_bitbucket b/src/modules/beamos/filesystem/known_hosts_bitbucket deleted file mode 100644 index af50ebf7..00000000 --- a/src/modules/beamos/filesystem/known_hosts_bitbucket +++ /dev/null @@ -1,2 +0,0 @@ -bitbucket.org,2406:da00:ff00::6b17:d1f5 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw== - diff --git a/src/modules/beamos/filesystem/migration/etc/systemd/system/migrationos_to_beamos2.service b/src/modules/beamos/filesystem/migration/etc/systemd/system/migrationos_to_beamos2.service new file mode 100644 index 00000000..212659f0 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/etc/systemd/system/migrationos_to_beamos2.service @@ -0,0 +1,12 @@ +[Unit] +Description=Migration Service +After=mrbeam_ledstrips.service socket.service + +[Service] +Type=simple +# add a delay to make sure ledstrips are up and running +ExecStartPre=/bin/sleep 10 +ExecStart=/usr/bin/migrationos_to_beamos2.sh + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/beamos/filesystem/migration/home/pi/image/README b/src/modules/beamos/filesystem/migration/home/pi/image/README new file mode 100644 index 00000000..fb7b2992 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/home/pi/image/README @@ -0,0 +1,11 @@ +# Beam OS 2 Image and bmap File + +This directory is intended for storing the "Beam OS 2" image and bmap file. Please follow the instructions below: + +1. Place the "Beam OS 2" image file here. The name of the image file should be: `beamos2.wic.bz2`. +2. Place the bmap file here. The name of the bmap file should be: `beamos2.wic.bmap`. +3. Use the `migrationos_to_beamos2.sh` script to flash the SD card with the Beam OS 2 image. +4. The migration service will automatically run the `migrationos_to_beamos2.sh` script. +5. No manual interaction is required during the migration process. + +For any further assistance, please refer to the documentation or contact the support team. diff --git a/src/modules/beamos/filesystem/migration/usr/bin/migration.sh b/src/modules/beamos/filesystem/migration/usr/bin/migration.sh new file mode 100755 index 00000000..d5601bc8 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/usr/bin/migration.sh @@ -0,0 +1,768 @@ +#!/bin/bash +# bash required for array syntax support. +# This is a copy of the migration.sh script from the mrb3-usb-stick-builder repo. + +echo "Beam OS1 to Beam OS2 Migration Script" + +usage () { + echo "Beam OS1 to Beam OS2 Migration Script v1.5.5 " + echo " " + echo "OPTIONS: " + echo " " + echo " --help Print this help message and exit. " + echo " " + echo "COMMANDS: " + echo " precondition-checks Checks the sw and hw components so that Mr Beam can be upgrade or not. " + echo " - is derived from the USB_ROOT. " + echo " flash Flashes the with using . " + echo " - can be \"beamos2\" or \"migrationos\". " + echo " - can be \"sd-card\" or device path like \"/dev/sda\". " + echo " mount Mounts the partitions of . " + echo " - can be \"sd-card\" or device path like \"/dev/sda\". " + echo " - is the number of partitions to be mounted. " + echo " will be used in Phase 1 only. " + echo " preserve-data Preserves sensitive data into USB at path \"/mnt/usb\". " + echo " restore-data Restores sensitive data into SD-Card. " + echo " set-status Sets the of LED in a " + echo " can be one of the following: " + echo " - success " + echo " - fail " + echo " can be one of the following: " + echo " - red,blue,green,orange,yellow,purple,teal(in specific error case) " + echo " config-boot-usb Configures Mr Beam to be able to boot from USB. " + echo " reboot Reboot Mr Beam. " + +} + +timestamp() +{ + date +"%Y-%m-%d %T" +} + +do_precondition_checks () { + MNT_PATH="$1" + echo "$(timestamp) $0: precondition-checks $MNT_PATH." + + configfile="/home/pi/.octoprint/config.yaml" + + # Check the size of SD-Card + echo "$(timestamp) $0: Checking the size of SD-Card." + local SD_CARD_SIZE=$(lsblk -b -o SIZE,TYPE /dev/mmcblk0 | grep "disk" | awk '{print $1}') + SD_CARD_SIZE_GIGABYTES=$((SD_CARD_SIZE / 1024 / 1024 / 1024)) + echo "$(timestamp) $0: SD-Card size - ${SD_CARD_SIZE_GIGABYTES}GB found" + if [ "$SD_CARD_SIZE" -gt $((MIN_SD_SIZE_IN_GB * 1024 * 1024 * 1024)) ]; then + echo "$(timestamp) $0: SD-Card size is greater than ${MIN_SD_SIZE_IN_GB}GB. Migration can be done." + else + echo "$(timestamp) $0: SD-Card size must be greater than ${MIN_SD_SIZE_IN_GB}GB for Migration." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + + # Check for free available space on SD-Card 4GB + echo "$(timestamp) $0: Checking the free available space on SD-Card." + local FREE_SD_CARD_SPACE=$(df -B 1k / | awk 'NR==2 {print $4}') + SD_CARD_FREE_SPACE_GIGABYTES=$((FREE_SD_CARD_SPACE / 1024 / 1024)) + echo "$(timestamp) $0: Free space on SD-Card - ${SD_CARD_FREE_SPACE_GIGABYTES}GB found" + if [ "$FREE_SD_CARD_SPACE" -gt $((MIN_SD_FREE_SPACE_IN_GB * 1024 * 1024)) ]; then + echo "$(timestamp) $0: Free space on SD-Card is greater than ${MIN_SD_FREE_SPACE_IN_GB}GB. Migration can be done." + else + echo "$(timestamp) $0: Free space on SD-Card must be greater than ${MIN_SD_FREE_SPACE_IN_GB}GB for Migration." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + + local MIN_REQ_MRBEAM_PLUGIN_VERSION="0.15.1" + #Check the MrBeamPlugin version + mrbeam_plugin_version=$(/home/pi/oprint/bin/pip list | grep Mr-Beam | awk '{gsub(/[()]/,""); print $2}') + + if $(dpkg --compare-versions "$mrbeam_plugin_version" "lt" $MIN_REQ_MRBEAM_PLUGIN_VERSION); then + echo "$(timestamp) $0: MrBeamPlugin version - $mrbeam_plugin_version must be greater than $MIN_REQ_MRBEAM_PLUGIN_VERSION for Migration." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + echo "$(timestamp) $0: MrBeamPlugin version is $mrbeam_plugin_version. Migration can be done." + + # Create a file to store the list of files to skip backing up + sudo touch ${SKIP_FILE_NAME} || true + echo "" > ${SKIP_FILE_NAME} + # Check if salt is present in config.yaml and decide if users.yaml, users-dev.yaml should be preserved or not + is_salt_in_config=$(( $(sed -n 's/^[[:space:]]*salt:[[:space:]]*\(.*\)/\1/p' "$configfile" | wc -c) > 0 )) + if [ $is_salt_in_config -eq 0 ]; then + echo "$(timestamp) $0: Salt is not present in config.yaml. Files will be skipped in preserve-data." + sed -i -e '$a\' -e '/home\/pi\/.octoprint\/users.yaml' -e '$a\' -e '/home\/pi\/.octoprint\/users-dev.yaml' ${SKIP_FILE_NAME} + fi + + # Verify integrity of /etc/mrbeam file. Fail if any field is empty or file doesnt exist. + # Check if the file exists + if [ ! -f "/etc/mrbeam" ]; then + echo "$(timestamp) $0: /etc/mrbeam file not found." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + # Read each line from the file + while IFS= read -r line; do + # Check if the line is not empty + if [ -n "$line" ]; then + # Split the line into key and value + key=$(echo "$line" | cut -d'=' -f1) + value=$(echo "$line" | cut -d'=' -f2-) + + # Check if the value is empty + if [ -z "$value" ]; then + echo "$(timestamp) $0: File /etc/mrbeam is corrupt. Empty value for key: $key" + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + fi + done < "/etc/mrbeam" + echo "$(timestamp) $0: /etc/mrbeam is valid. No empty fields found." + + # Get the list of USB block devices with sizes in bytes + USB_DRIVES=$(lsblk -o NAME,SIZE,TYPE,TRAN -dn --bytes | grep 'usb' | awk '{print $1,$2}') + + # Check if there are any USB drives + if [ -z "$USB_DRIVES" ]; then + echo "$(timestamp) $0: No USB drives found." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + + while read -r line; do + DEVICE_SIZE_BYTES=$(echo "$line" | awk '{print $2}') + + # Check if the size is greater than 4GB + if [ "$DEVICE_SIZE_BYTES" -gt $((MIN_USB_SIZE_IN_GB * 1024 * 1024 * 1024)) ]; then + DEVICE_SIZE_GIGABYTES=$((DEVICE_SIZE_BYTES / 1024 / 1024 / 1024)) + echo "$(timestamp) $0: USB drive of $DEVICE_SIZE_GIGABYTES GB present." + else + echo "$(timestamp) $0: No USB drive of size greater than ${MIN_USB_SIZE_IN_GB}GB found." + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + + done <<< "$USB_DRIVES" + + MIGRATIONOS_ENC_PATH="${MNT_PATH}/migrationos.enc" + # Check if valid MigrationOS encrypted is present + if [ -f ${MIGRATIONOS_ENC_PATH} ]; then + echo "$(timestamp) $0: Found valid MigrationOS encrypted: ${MIGRATIONOS_ENC_PATH}" + # verify gpg signature + if gpg --verify "${MIGRATIONOS_ENC_PATH}"; then + echo "$(timestamp) $0: GPG signature verified for ${MIGRATIONOS_ENC_PATH}" + else + echo "$(timestamp) $0: GPG signature verification failed for ${MIGRATIONOS_ENC_PATH}" + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + else + echo "$(timestamp) $0: MigrationOS encrypted file ${MIGRATIONOS_ENC_PATH} not found" + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 101 + fi + + # Decryption of migrationos.enc as migrationos.img onto /home/pi/usb_mount directory + echo "$(timestamp) $0: Decrypting ${MIGRATIONOS_ENC_PATH} to ${MIGRATION_IMAGE_BASEDIR}" + gpg --output ${MIGRATION_IMAGE_BASEDIR} --decrypt ${MIGRATIONOS_ENC_PATH} + if [ $? -ne 0 ]; then + echo "$(timestamp) $0: Decryption failed for ${MIGRATIONOS_ENC_PATH}" + sudo cp ${LOG_FILE} ${MNT_PATH}/beamos1_to_migrationos.log + exit 102 + fi + echo "$(timestamp) $0: Decryption successful for ${MIGRATIONOS_ENC_PATH} to ${MIGRATION_IMAGE_BASEDIR}" + + #Exit on success + exit 0 +} + + +find_current_booted_os_version () { + if [ -f /etc/beamos_version ] || [ -f /etc/octopi_version ] ; then + echo "beamos1" + elif [ -f /etc/migrationos_version ]; then + echo "migrationos" + fi +} + +do_flash () { + OS_TO_BE_FLASHED="$1" + DEVICE_TO_BE_FLASHED="$2" + echo "$(timestamp) $0: flash $OS_TO_BE_FLASHED $DEVICE_TO_BE_FLASHED" + + CURRENT_OS_VERSION=$(find_current_booted_os_version) + echo "$(timestamp) $0: Flashing $OS_TO_BE_FLASHED on $DEVICE_TO_BE_FLASHED from $CURRENT_OS_VERSION" + if [ "$OS_TO_BE_FLASHED" = "beamos2" ] && [ "$DEVICE_TO_BE_FLASHED" = "sd-card" ] && [ "$CURRENT_OS_VERSION" = "migrationos" ]; then + echo "Flashing SD-Card with beamos2" + IMAGE_FILE="${BEAMOS2_IMAGE}" + # check if the image is there + if [ ! -f ${IMAGE_FILE} ]; then + echo "$(timestamp) $0: Image not found: ${IMAGE_FILE}" + exit 103 + fi + sudo umount ${SD_CARD_DEVICE}* || true + sudo bmaptool copy ${IMAGE_FILE} ${SD_CARD_DEVICE} + STATUS=$? + FLASH_COLOR_ON_FAIL_TO_FLASH="orange" + elif [ "$OS_TO_BE_FLASHED" = "migrationos" ] && [ "$CURRENT_OS_VERSION" = "beamos1" ];then + # check if the image is there + IMAGE_FILE="${MIGRATION_IMAGE}" + if [ ! -f ${IMAGE_FILE} ]; then + echo "$(timestamp) $0: Image not found: ${IMAGE_FILE}" + exit 104 + fi + echo "$(timestamp) $0: Flashing USB with migrationos" + sudo umount ${DEVICE_TO_BE_FLASHED}* || true + sudo dd if=${IMAGE_FILE} of=${DEVICE_TO_BE_FLASHED} bs=4M conv=fsync + STATUS=$? + FLASH_COLOR_ON_FAIL_TO_FLASH="yellow" + else + echo "$(timestamp) $0: Check inputs to the function flash" + exit 105 + fi + + # check status of flashing + if [ $STATUS -ne 0 ]; then + echo "$(timestamp) $0: Flashing Failed - $OS_TO_BE_FLASHED on $DEVICE_TO_BE_FLASHED from $CURRENT_OS_VERSION" + if [ $FLASH_COLOR_ON_FAIL_TO_FLASH = "orange" ]; then + exit 103 + elif [ $FLASH_COLOR_ON_FAIL_TO_FLASH = "yellow" ]; then + exit 106 + fi + fi + + sudo sync + + echo "$(timestamp) $0: Flashing Successful - $OS_TO_BE_FLASHED flashed into $DEVICE_TO_BE_FLASHED " + exit 0 +} + +do_mount () { + DEVICE_TO_BE_MOUNTED="$1" + NUMPART="$2" + echo "$(timestamp) $0: mount $DEVICE_TO_BE_MOUNTED" # "sd-card" or usb path like "/dev/sda" + CURRENT_OS_VERSION=$(find_current_booted_os_version) + + if [ "$DEVICE_TO_BE_MOUNTED" = "sd-card" ] && [ "$CURRENT_OS_VERSION" = "migrationos" ]; then + # Mounting the SD-Card + DEVICE_PARTITIONS=( + ${SDCARD_ROOTFS_A} + ${SDCARD_ROOTFS_B} + ${SDCARD_HOME} + ) + + MOUNT_DIRS=( + ${SDCARD_ROOTFS_A_PATH} + ${SDCARD_ROOTFS_B_PATH} + ${SDCARD_HOME_PATH} + ) + FLASH_COLOR_ON_FAIL_TO_MOUNT="orange" + elif [ "$DEVICE_TO_BE_MOUNTED" != "sd-card" ] && [ "$CURRENT_OS_VERSION" = "beamos1" ];then + # Mounting the USB with migrationos + # There are 3 partitions on the USB. The first one is the boot partition, the second one is the rootfs, third is log partition + DEVICE_ROOTFS_PARTITION=${DEVICE_TO_BE_MOUNTED}2 + DEVICE_LOG_PARTITION=${DEVICE_TO_BE_MOUNTED}3 + + DEVICE_PARTITIONS=( + ${DEVICE_ROOTFS_PARTITION} + ${DEVICE_LOG_PARTITION} + ) + + MOUNT_DIRS=( + ${USB_MOUNT_PATH} + ${USB_MOUNT_PATH}1 + ) + + if [ ${NUMPART} -eq 1 ]; then + echo "$(timestamp) $0: Unsetting the extra partitions so that there is no severe errors." + unset DEVICE_PARTITIONS[1] + unset MOUNT_DIRS[1] + fi + # Re-index the arrays + DEVICE_PARTITIONS=("${DEVICE_PARTITIONS[@]}") + MOUNT_DIRS=("${MOUNT_DIRS[@]}") + + FLASH_COLOR_ON_FAIL_TO_MOUNT="blue" + else + echo "$(timestamp) $0: Check inputs to the function mount" + exit 105 + fi + + for i in "${!DEVICE_PARTITIONS[@]}"; do + sudo mkdir -p ${MOUNT_DIRS[$i]} + echo "$(timestamp) $0: Mounting ${DEVICE_PARTITIONS[$i]} on ${MOUNT_DIRS[$i]}" + sudo mount ${DEVICE_PARTITIONS[$i]} ${MOUNT_DIRS[$i]} + # Check if the mount is successful + if [ $? -ne 0 ]; then + echo "$(timestamp) $0: Can't mount ${DEVICE_PARTITIONS[$i]}" + if [ $FLASH_COLOR_ON_FAIL_TO_MOUNT = "orange" ]; then + exit 103 + elif [ $FLASH_COLOR_ON_FAIL_TO_MOUNT = "blue" ]; then + exit 104 + fi + fi + done + + echo "Mounting Successful - $DEVICE_TO_BE_MOUNTED" + exit 0 +} + + +do_preserve_data () { + echo "$(timestamp) $0: preserve-data $USB_MOUNT_PATH" # path like "/mnt/usb" + if ! grep -qs "${USB_MOUNT_PATH}" /proc/mounts; then + echo "$(timestamp) $0: No suitable backup partition found. Exiting..." + exit 104 + fi + echo "$(timestamp) $0: Backing up data to ${USB_MOUNT_PATH}" + # Create a backup directory (if it doesn't exist) + BACKUP_BASE="${USB_MOUNT_PATH}${BACKUP_PATH}" + + # Check if the folder exists, backup if yes. + if [ -d "${BACKUP_BASE}" ]; then + # Get the creation time of the folder + creation_time=$(stat -c %W "${BACKUP_BASE}") + + # Format the creation time as a timestamp + timestamp=$(date -d "@$creation_time" +"%Y%m%d_%H%M%S") + + # Rename the folder by adding the timestamp + new_folder_name="${BACKUP_BASE}_backup_${timestamp}" + mv "${BACKUP_BASE}" "${new_folder_name}" + + echo "$(timestamp) $0: ${BACKUP_BASE} exists. Moved it to: ${new_folder_name}" + fi + + mkdir -p "$BACKUP_BASE" + + mapfile -t LIST_TO_SKIP < ${SKIP_FILE_NAME} + + SKIPPED=0 + + # Loop through each file in the array and create a backup copy + for FILE in "${DATA_TO_PRESERVE[@]}"; do + if [ -f "${FILE}" ] || [ -d "${FILE}" ]; then + if [[ " ${LIST_TO_SKIP[@]} " =~ " $FILE " ]]; then + echo "$(timestamp) $0: Warning - File ${FILE} skipped as salt is not present in config.yaml" + ((SKIPPED++)) + continue + fi + TARGET_DIR="${BACKUP_BASE}/$(dirname "${FILE}")" + mkdir -p ${TARGET_DIR} + TARGET="${TARGET_DIR}/$(basename "${FILE}")" + cp -r "${FILE}" "${TARGET}" + echo "$(timestamp) $0: Success - copied '${FILE}' to '${TARGET}'" + else + echo "$(timestamp) $0: Warning - File '${FILE}' not found. Skipping." + ((SKIPPED++)) + fi + done + + echo "$(timestamp) $0:Copying ${MIGRATION_OPERATOR_FILE} to ${USB_MOUNT_PATH}/${MIGRATION_OPERATOR_FILE}" + sudo cp ${MIGRATION_OPERATOR_FILE} ${USB_MOUNT_PATH}/${MIGRATION_OPERATOR_FILE} + + echo "$(timestamp) $0: Backup process completed. Backup copies are stored in '$BACKUP_BASE'." + if [ "${SKIPPED}" -gt 0 ]; then + echo "$(timestamp) $0: Warning - ${SKIPPED} files were skipped - Please check syslog." + # exit 1 + fi + + exit 0 +} + +do_restore_data () { + echo "$(timestamp) $0: restore-data" + + # /etc/hostname -> Rootfs A and B -> /etc/hostname + echo "$(timestamp) $0: Restoring /etc/hostname to Rootfs A and B /etc/hostname" + sudo cp ${BACKUP_PATH}/etc/hostname ${SDCARD_ROOTFS_A_PATH}/etc/hostname + sudo cp ${BACKUP_PATH}/etc/hostname ${SDCARD_ROOTFS_B_PATH}/etc/hostname + + # /etc/hosts -> Home -> /home/root/mrbeam-base-files/hosts + echo "$(timestamp) $0: Restoring /etc/hosts to Home /home/root/mrbeam-base-files/hosts" + sudo cp ${BACKUP_PATH}/etc/hosts ${SDCARD_HOME_PATH}/root/mrbeam-base-files/hosts + + # /etc/mrbeam -> Home -> /home/pi/mrbeam-id/mrbeam + # We need to understand backed up from beamos0 or beamos1 + echo "$(timestamp) $0: Restoring /etc/mrbeam to Home /home/pi/mrbeam-id/mrbeam" + local MRBEAM_SECTION="Mr Beam" + sudo crudini --get "${BACKUP_PATH}/etc/mrbeam" "$MRBEAM_SECTION" "production_date" + if [ $? -ne 0 ]; then + # We are migrating from beamos0 + echo "$(timestamp) $0: Migrating from beamos0" + SECTION="" + else + # We are migrating from beamos1 + echo "$(timestamp) $0: Migrating from beamos1" + SECTION="Mr Beam" + fi + # Below params will be set to the new mrbeam file + PARAMS="production_date hostname device_series device_type serial model" + for param in $PARAMS; do + local VALUE=$(sudo crudini --get "${BACKUP_PATH}/etc/mrbeam" "$SECTION" "$param") + echo "$(timestamp) $0: Setting $param to $VALUE" + sudo crudini --set "${SDCARD_HOME_PATH}/pi/mrbeam-id/mrbeam" "$MRBEAM_SECTION" "$param" "${VALUE}" + done + local OCTOPI=$(sudo crudini --get "${BACKUP_PATH}/etc/mrbeam" "$SECTION" "octopi") + # Set migrated_from param + echo "$(timestamp) $0: Setting migrated_from to $OCTOPI" + sudo crudini --set "${SDCARD_HOME_PATH}/pi/mrbeam-id/mrbeam" "$MRBEAM_SECTION" "migrated_from" "${OCTOPI}" + # Set need_reboot param + sudo crudini --set "${SDCARD_HOME_PATH}/pi/mrbeam-id/mrbeam" "$MRBEAM_SECTION" "need_reboot" true + + # .octoprint/config.yaml -> Home -> /home/pi/.octoprint/config.yaml + # We need to copy fields from the backup to the new config.yaml + backupfolder="${BACKUP_PATH}" + applyfolder="${SDCARD_HOME_PATH}/.." + configfile="/home/pi/.octoprint/config.yaml" + backupfile="${backupfolder}${configfile}" + applyfile="${applyfolder}${configfile}" + migrationoperator=$(sudo cat ${MIGRATION_OPERATOR_FILE}) + #accessControl needed for users.yaml + echo "$(timestamp) $0: Restoring accessControl for $configfile" + accessControl=$(sudo yq eval '.accessControl' $backupfile) + salt=$(sudo yq eval '.accessControl.salt' $backupfile) + # Check if the accessControl field is empty or salt is null + if [ -z "$accessControl" ] || [ "$salt" == "null" ]; then + echo "$(timestamp) $0: Warning - accessControl field is empty in $backupfile. Remove users.yaml files from to be restored file list." + DATA_TO_RESTORE=("${DATA_TO_RESTORE[@]/".octoprint/users.yaml"}") + DATA_TO_RESTORE=("${DATA_TO_RESTORE[@]/".octoprint/users-dev.yaml"}") + else + sudo cat $backupfile | sudo yq ea -i 'select(fileIndex==0) * {"accessControl":select(fileIndex==1).accessControl}' $applyfile - + fi + + #plugins.findmymrbeam + echo "$(timestamp) $0: Restoring plugins.findmymrbeam for $configfile" + findmymrbeam=$(sudo yq eval '.plugins.findmymrbeam' $backupfile) + # Check if the findmymrbeam field is empty or null + if [ -z "$findmymrbeam" ] || [ "$findmymrbeam" == "null" ]; then + echo "$(timestamp) $0: Warning - findmymrbeam field is empty in $backupfile. Skipping." + else + sudo cat $backupfile | sudo yq ea -i 'select(fileIndex==0) * {"plugins":{"findmymrbeam":select(fileIndex==1).plugins.findmymrbeam}}' $applyfile - + fi + + #plugins.mrbeam.analyticsEnabled + echo "$(timestamp) $0: Restoring plugins.mrbeam.analyticsEnabled for $configfile" + analyticsEnabled=$(sudo yq eval '.plugins.mrbeam.analyticsEnabled' $backupfile) + # Check if the analyticsEnabled field is empty or null + if [ -z "$analyticsEnabled" ] || [ "$analyticsEnabled" == "null" ]; then + echo "$(timestamp) $0: Warning - analyticsEnabled field is empty in $backupfile. Skipping." + else + sudo cat $backupfile | sudo yq ea -i 'select(fileIndex==0) * {"plugins":{"mrbeam":{"analyticsEnabled":select(fileIndex==1).plugins.mrbeam.analyticsEnabled}}}' $applyfile - + fi + + #plugins.mrbeam.review + echo "$(timestamp) $0: Restoring plugins.mrbeam.review for $configfile" + review=$(sudo yq eval '.plugins.mrbeam.review' $backupfile) + # Check if the review field is empty or null + if [ -z "$review" ] || [ "$review" == "null" ]; then + echo "$(timestamp) $0: Warning - review field is empty in $backupfile. Skipping." + else + sudo cat $backupfile | sudo yq ea -i 'select(fileIndex==0) * {"plugins":{"mrbeam":{"review":select(fileIndex==1).plugins.mrbeam.review}}}' $applyfile - + fi + + #plugins.swupdater.attributes.migration_operator + echo "$(timestamp) $0: Set plugins.swupdater.attributes.migration_operator as $migrationoperator for $configfile" + sudo yq e -i ".plugins.swupdater |= {\"attributes\": {\"migration_operator\": \"$migrationoperator\"}}" $applyfile + + #We now set a field to identify this as a first boot after upgrade + #plugins.mrbeam.firstBootAfterUpgrade + echo "$(timestamp) $0: Set plugins.mrbeam.firstBootAfterUpgrade for $configfile" + sudo yq eval -i '.plugins.mrbeam.firstBootAfterUpgrade = true' $applyfile + + # Run python script to sanitize lens calibration files + echo "$(timestamp) $0: Sanitizing lens calibration files" + sanitize_npz.py + + # Loop through the rest of the files and folders in the array and copy backed up files + echo "$(timestamp) $0: Restoring the rest of the files to Home" + for FILE in "${DATA_TO_RESTORE[@]}"; do + BACKUP_FILE="${BACKUP_PATH}/home/pi/${FILE}" + if [ -f "${BACKUP_FILE}" ] || [ -d "${BACKUP_FILE}" ]; then + TARGET_DIR="${SDCARD_HOME_PATH}/pi/$(dirname "${FILE}")" + sudo mkdir -p ${TARGET_DIR} + TARGET="${TARGET_DIR}/$(basename "${FILE}")" + echo "$(timestamp) $0: Restoring ${BACKUP_FILE} to ${TARGET}" + sudo cp -r "${BACKUP_FILE}" "${TARGET}" + else + echo "$(timestamp) $0: Restore data: Warning - File '${FILE}' not found. Skipping." + fi + done + + # Give admin permission to all users in the users.yaml file + # This is default in our implementation of OctoPrint access control + usersyamlfilelist=( + "${SDCARD_HOME_PATH}/pi/.octoprint/users.yaml" + "${SDCARD_HOME_PATH}/pi/.octoprint/users-dev.yaml" + ) + + for usersyamlfile in "${usersyamlfilelist[@]}"; do + if [ ! -f "$usersyamlfile" ]; then + echo "$(timestamp) $0: Restore data: Warning - File '${usersyamlfile}' not found. Skipping." + continue + fi + # Extract email addresses with a trailing colon + email_list=$(grep -E -o '\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b:' "$usersyamlfile" | sed 's/:$//') + + # Check if the email_list is empty + if [ -z "$email_list" ]; then + echo "$(timestamp) $0: Restore data: Warning - No email addresses found in '${usersyamlfile}'. Removing it." + sudo rm -f "$usersyamlfile" + continue + fi + + # Check if there are any active users + active_user=$(sudo yq eval '.. | select(has("active")) | .active' "$usersyamlfile" | grep true) + if [ -z "$active_user" ]; then + echo "$(timestamp) $0: Restore data: Warning - No active user found in '${usersyamlfile}'. Removing it." + sudo rm -f "$usersyamlfile" + continue + fi + + for email in $email_list; do + # Check if 'admin' role already exists for the email + admin_exists=$(sudo yq eval ".\"$email\".roles | select(.[] == \"admin\")" "$usersyamlfile") + + # If 'admin' role does not exist, append it + if [ -z "$admin_exists" ]; then + sudo yq eval -i ".\"$email\".roles += [\"admin\"]" "$usersyamlfile" + fi + + # Check if 'groups' field exists for the email + groups_exists=$(yq eval ".\"$email\".groups" "$usersyamlfile") + + # If 'groups' field does not exist, add it with specified values + if [ "$groups_exists" == "null" ]; then + sudo yq eval -i ".\"$email\".groups = [\"admins\", \"users\"]" "$usersyamlfile" + fi + done + done + + echo "$(timestamp) $0: Restore data: Restore process completed." + exit 0 +} + +FLASH_PURPLE="color:128:0:128" +FLASH_TEAL="color:10:100:100" + +set_status_success() { + echo "$(timestamp) $0: status_success $1" + STAGE_COLOR="$1" + for ((i=0; i<3; i++)); do + mrbeam_ledstrips_cli flash_$STAGE_COLOR + sleep 0.5 + mrbeam_ledstrips_cli flash_green + sleep 0.5 + done +} + +set_status_fail () { + echo "$(timestamp) $0: status_fail" + while true + do + mrbeam_ledstrips_cli flash_$1:1 + sleep 1 + mrbeam_ledstrips_cli flash_red + sleep 1 + done +} + +set_status_warn () { + echo "$(timestamp) $0: status_warn" + mrbeam_ledstrips_cli flash_$1:1; +} + +do_set_status () { + STATUS="$1" + COLOR="$2" + echo "$(timestamp) $0: set-status ${STATUS}" + if [ "${STATUS}" = "success" ]; then + echo "${STATUS}" + set_status_success "$COLOR" + elif [ "${STATUS}" = "fail" ]; then + echo "${STATUS}" + set_status_fail "$COLOR" & + else + echo "$(timestamp) $0: Unknown status [${STATUS}]" + set_status_fail red & + fi +} + +do_config_boot_usb () { + echo "$(timestamp) $0: config-boot-usb" + echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt + sudo sed -i '$ s|$| root=/dev/sda2|' /boot/cmdline.txt + echo "$(timestamp) $0: Device configured to boot from USB." + exit 0 +} + +do_reboot () { + echo "$(timestamp) $0: reboot" + sudo reboot now + exit 0 +} + + +do_exit () { + RET_CODE="$?" + echo "$0: Exitting. ${RET_CODE}" + if [ "$RET_CODE" -eq 0 ]; then + echo "$0: Normal exiting." + else + echo "$0: Exiting with error code [${RET_CODE}]" + if [ "${RET_CODE}" -eq 101 ]; then + do_set_status fail ${FLASH_PURPLE} + elif [ "${RET_CODE}" -eq 102 ]; then + do_set_status fail ${FLASH_TEAL} + elif [ "${RET_CODE}" -eq 103 ]; then + do_set_status fail orange + elif [ "${RET_CODE}" -eq 104 ]; then + do_set_status fail blue + elif [ "${RET_CODE}" -eq 105 ]; then + do_set_status fail red + elif [ "${RET_CODE}" -eq 106 ]; then + do_set_status fail yellow + fi + fi +} + +################################################################################ +## migration.sh script configuration +################################################################################ + +MIGRATIONOS_ENC="migrationos.enc" +BASEDIR="/home/pi/usb_mount" +MIGRATION_IMAGE_BASEDIR=${BASEDIR}/migrationos.img +IMAGE_DIR="/home/pi/image" +MIGRATION_IMAGE="${IMAGE_DIR}/migrationos.img" +BEAMOS2_IMAGE="${IMAGE_DIR}/beamos2.wic.bz2" +MIGRATION_OPERATOR_FILE="${IMAGE_DIR}/migrationoperator" +MIN_USB_SIZE_IN_GB=4 +MIN_SD_SIZE_IN_GB=12 +MIN_SD_FREE_SPACE_IN_GB=4 +BACKUP_PATH="/mrbeam/preserve-data" +SKIP_FILE_NAME="./files_to_skip_preserve_data" +LOG_FILE="/var/log/mount_manager.log" + +# There are 8 partitions on the SD-Card. +# Root filesystems are on partition 2 and 3. +# Home is on partition 8. +SD_CARD_DEVICE="/dev/mmcblk0" +SDCARD_ROOTFS_A="${SD_CARD_DEVICE}p2" +SDCARD_ROOTFS_B="${SD_CARD_DEVICE}p3" +SDCARD_HOME="${SD_CARD_DEVICE}p8" + +SDCARD_ROOTFS_A_PATH="/mnt/sd-card/rootfs_a" +SDCARD_ROOTFS_B_PATH="/mnt/sd-card/rootfs_b" +SDCARD_HOME_PATH="/mnt/sd-card/home" + +USB_MOUNT_PATH="/mnt/usb" + +# list of files treated by preserve-data and restore-data +DATA_TO_PRESERVE=( + "/home/pi/.octoprint/cam" # is a folder + "/home/pi/.octoprint/analytics/usage.yaml" + "/home/pi/.octoprint/users.yaml" + "/home/pi/.octoprint/users-dev.yaml" + "/home/pi/.octoprint/materials.yaml" + "/home/pi/.octoprint/laser_heads.yaml" + "/home/pi/.octoprint/config.yaml" + "/etc/mrbeam" + "/etc/network/interfaces" + "/etc/hostname" + "/etc/hosts" + "/etc/network/interfaces.d/wlan0-netconnectd_wifi" + "/var/log/mount_manager.log" + # Add more file paths as needed +) + +DATA_TO_RESTORE=( + ".octoprint/cam" # is a folder + ".octoprint/analytics/usage.yaml" + ".octoprint/users.yaml" + ".octoprint/users-dev.yaml" + ".octoprint/materials.yaml" + # Other files are required manual intervention to restore +) + + +################################################################################ +## Main +################################################################################ + + +# Present usage. +if [ $# -eq 0 ]; then + usage + exit 0 +fi + +while getopts ":h?:" opt; do + case "$opt" in + h|\?) + usage + exit 0 + ;; + esac +done + +# Set trap before EXIT +trap do_exit EXIT + +# Process all commands. +while true ; do + case "$1" in + precondition-checks) + do_precondition_checks "$2" + shift + shift + break + ;; + flash) + do_flash "$2" "$3" + shift + shift + shift + break + ;; + mount) + do_mount "$2" "$3" + shift + shift + shift + break + ;; + preserve-data) + do_preserve_data + shift + break + ;; + restore-data) + do_restore_data + shift + break + ;; + set-status) + do_set_status "$2" "$3" + shift + shift + shift + break + ;; + config-boot-usb) + do_config_boot_usb + shift + break + ;; + reboot) + do_reboot + shift + break + ;; + *) + if [[ -n "$1" ]]; then + echo "$0: Unknown command [${1}]" + usage + fi + break + ;; + esac +done diff --git a/src/modules/beamos/filesystem/migration/usr/bin/migrationos_to_beamos2.sh b/src/modules/beamos/filesystem/migration/usr/bin/migrationos_to_beamos2.sh new file mode 100755 index 00000000..fd0cac31 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/usr/bin/migrationos_to_beamos2.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +# This script is used to flash the Beam OS 2 to the SD-Card. +# Then the Mr Beam will start to Beam OS 2. + +# This script uses migration.sh script + +# Usage: +# Flash the SD-Card +# Mount the SD-Card +# Restore Sensitive Data +# Set LED Status Success/Fail +# Reboot the device + +timestamp() +{ + date +"%Y-%m-%d %T" +} + +## functions for logging output +log() { + echo "$(date +"%Y.%m.%d %H:%M:%S") $SCRIPTNAME> $1" 2>&1 | tee -a $LOG_FILE | tee -a $2 >> /dev/null +} + +cmd() { + # tee does not complain if $2 is not set + echo "$(date +"%Y.%m.%d %H:%M:%S") $SCRIPTNAME> $1" 2>&1 | tee -a $LOG_FILE | tee -a $2 >> /dev/null + eval "$1" 2>&1 | tee -a $LOG_FILE | tee -a $2 >> /dev/null + return ${PIPESTATUS[0]} +} + +do_exit() +{ + RET_CODE="$?" + log "$(timestamp) $0: Exitting. ${RET_CODE}" + if [ "$RET_CODE" -eq 0 ]; then + log "$0: Normal exiting." + sudo bash ${BASEDIR}/migration.sh set-status success orange + else + log "$0: Exiting with error code [${RET_CODE}]" + sudo bash ${BASEDIR}/migration.sh set-status fail orange + fi +} + + +############################################### +# Constants +############################################### +BASEDIR="/usr/bin" +SCRIPTNAME=$(basename "$BASH_SOURCE") + +LOG_LOCATION="/mnt/usb" +LOG_FILE="${LOG_LOCATION}/migrationos_to_beamos2.log" + +SYSLOG_LOCATION="/var/log/syslog" +SYSLOG_BACKUP="${LOG_LOCATION}/migrationos_syslog.log" + +SDCARD_ROOTFS_A_PATH="/mnt/sd-card/rootfs_a" +SDCARD_ROOTFS_B_PATH="/mnt/sd-card/rootfs_b" + +IMAGE_DIR="/home/pi/image" +BEAMOS2_IMAGE="${IMAGE_DIR}/beamos2.wic.bz2" +MAX_TIME=900 # 15 minutes in seconds +PHASE_COLOR="ORANGE" + + +############################################### +# Main function +############################################### + +# Set trap before EXIT +trap do_exit EXIT + +# find the right device name of partition 3 on the USB stick and mount it +echo "$(timestamp) $0: Mounting the USB stick partition 3" +USB_PART=$(lsblk -o NAME,SIZE -d -p -n | grep "/dev/sd" | awk '{print $1}') +USB_PARTITION="${USB_PART}3" +sudo mkdir -p ${LOG_LOCATION} +sudo fsck -a ${USB_PARTITION} +sudo mount ${USB_PARTITION} ${LOG_LOCATION} +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + echo "$(timestamp) $0: mount ${USB_PARTITION} on ${LOG_LOCATION} failed" +fi +echo "$(timestamp) $0: Mounting the USB stick partition 3 successful" + +# start progress leds +current_pid=$$ +sudo bash ${BASEDIR}/progress.sh $current_pid $MAX_TIME $PHASE_COLOR &>> $LOG_FILE & + +# Flash the SD-Card +log "$(timestamp) $0: Flashing the SD-Card" +cmd 'sudo bash ${BASEDIR}/migration.sh flash beamos2 sd-card' +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + log "$(timestamp) $0: Flashing the SD-Card failed" + exit 100 +fi + +# Mount the SD-Card +log "$(timestamp) $0: Mounting the SD-Card" +cmd 'sudo bash ${BASEDIR}/migration.sh mount sd-card' +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + log "$(timestamp) $0: Mounting the SD-Card failed" + exit 100 +fi + +# Restore Sensitive Data +log "$(timestamp) $0: Restoring Sensitive Data" +cmd 'sudo bash ${BASEDIR}/migration.sh restore-data' +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + log "$(timestamp) $0: Restoring Sensitive Data failed" + exit 100 +fi + +# Copy syslog to the USB stick +log "$(timestamp) $0: Copying syslog to the USB stick" +# Check if the file exists and rename it if it does +if [ -f ${SYSLOG_BACKUP} ]; then + cmd 'sudo mv ${SYSLOG_BACKUP} ${SYSLOG_BACKUP}.old' +fi +cmd 'sudo cp ${SYSLOG_LOCATION} ${SYSLOG_BACKUP}' +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + log "$(timestamp) $0: Copy syslog to the USB stick failed" +fi +log "$(timestamp) $0: Copying syslog to the USB stick successful" + +# Copy logs on the /mnt/usb to the freshly flashed SD-Card rootfs var log partition +log "$(timestamp) $0: Copying logs to the freshly flashed SD-Card rootfs var log partition" +log "$(timestamp) $0: System will reboot after this........" +sudo cp -r ${LOG_LOCATION}/* ${SDCARD_ROOTFS_A_PATH}/var/log/ +sudo cp -r ${LOG_LOCATION}/* ${SDCARD_ROOTFS_B_PATH}/var/log/ +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + echo "$(timestamp) $0: Copying logs to the freshly flashed SD-Card rootfs var log partition failed" +fi + +# Reboot the device +echo "$(timestamp) $0: Reboot the device" +sudo bash ${BASEDIR}/migration.sh set-status success orange +sudo bash ${BASEDIR}/migration.sh reboot +exit_code=$? +if [ "$exit_code" -ne 0 ]; then + echo "$(timestamp) $0: Reboot the device failed" + exit 100 +fi + +exit 0 diff --git a/src/modules/beamos/filesystem/migration/usr/bin/progress.sh b/src/modules/beamos/filesystem/migration/usr/bin/progress.sh new file mode 100755 index 00000000..766087e0 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/usr/bin/progress.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Check if PID and total time are provided +if [ $# -lt 2 ]; then + echo "Usage: $0 [color]" + exit 1 +fi + +pid=$1 +total_time=$2 +color=${3:-"BLUE"} + +# Check if the process exists +if ! ps -p $pid > /dev/null; then + echo "Process with PID $pid not found." + exit 1 +fi + +# Start tracking time +start_time=$(ps -o etimes= -p $pid) +last_percentage=0 +while ps -p $pid > /dev/null; do + current_time=$(ps -o etimes= -p $pid) + runtime=$((current_time - start_time)) + percentage=$((runtime * 100 / total_time)) + if [[ $percentage -ne $last_percentage && $percentage -lt 99 ]]; then + echo "Percentage of runtime: $percentage % ($runtime s)" + last_percentage=$percentage + if [ "$color" == "BLUE" ]; then + mrbeam_ledstrips_cli progress:$percentage + else + mrbeam_ledstrips_cli progress:$percentage:$color + fi + elif [[ $percentage -ge 99 ]]; then + exit 0 + fi + sleep 5 +done diff --git a/src/modules/beamos/filesystem/migration/usr/bin/sanitize_npz.py b/src/modules/beamos/filesystem/migration/usr/bin/sanitize_npz.py new file mode 100755 index 00000000..4d30c530 --- /dev/null +++ b/src/modules/beamos/filesystem/migration/usr/bin/sanitize_npz.py @@ -0,0 +1,54 @@ +#!/usr/bin/python3 +""" Module to santitize npz files to be compatible with python 3.x """ +import os +import shutil +import numpy as np + + +PRESERVE_DATA_CAM_DIRECTORY = "/mrbeam/preserve-data/home/pi/.octoprint/cam/" + +BUSTER_FACTORY_LENS_CALIBRATION = "factory_lens_correction.npz" +LEGACY_FACTORY_LENS_CALIBRATION = "lens_correction_2048x1536.npz" +USER_LENS_CALIBRATION = "lens_correction.npz" + +LENS_CALIBRATTION_FILES = [ + BUSTER_FACTORY_LENS_CALIBRATION, + LEGACY_FACTORY_LENS_CALIBRATION, + USER_LENS_CALIBRATION, +] + + +def sanitize_npz(npz_file: str) -> None: + """Sanitize npz files to be compatible with python 3.x. + + Args: + * npz_file (str) : path to the npz file to be sanitized + + Returns: + * None + + Raises: + * np.lib.format.FormatError: if the file is not a valid npz file + """ + print("Sanitizing: " + npz_file) + try: + data = np.load(npz_file, encoding="latin1", allow_pickle=True) + except np.lib.format.FormatError as _e: + print("Error loading file: " + str(_e)) + np.savez_compressed(npz_file, **data) + + +def sanitize_npz_files() -> None: + """Sanitize all npz files in the cam directory""" + for _f in LENS_CALIBRATTION_FILES: + npz_file = os.path.join(PRESERVE_DATA_CAM_DIRECTORY, _f) + if os.path.isfile(npz_file): + # create backup retain the original file + shutil.copy2(npz_file, npz_file + ".original") + sanitize_npz(npz_file) + else: + print("File not found: " + npz_file) + + +if __name__ == "__main__": + sanitize_npz_files() diff --git a/src/modules/beamos/filesystem/mount_manager/home/pi/usb_mount/README.md b/src/modules/beamos/filesystem/mount_manager/home/pi/usb_mount/README.md deleted file mode 100644 index 3b02ae57..00000000 --- a/src/modules/beamos/filesystem/mount_manager/home/pi/usb_mount/README.md +++ /dev/null @@ -1 +0,0 @@ -This is where the mount_manager shell script will mount the usb keys provided that they contain the correct key signature. diff --git a/src/modules/beamos/filesystem/mount_manager/root/etc/logrotate.d/mount_manager b/src/modules/beamos/filesystem/mount_manager/root/etc/logrotate.d/mount_manager deleted file mode 100644 index 342119ce..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/etc/logrotate.d/mount_manager +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/mount_manager.log { - size 2M - rotate 3 - compress - delaycompress - missingok - notifempty - copytruncate - create 644 root root - dateext - dateformat .%Y-%m-%d -} diff --git a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_add.service b/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_add.service deleted file mode 100644 index d34012ff..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_add.service +++ /dev/null @@ -1,6 +0,0 @@ -[Service] -Type=oneshot -ExecStart=/usr/bin/mount_manager add - -[Unit] -After=mount_manager_remove.service diff --git a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_clear.service b/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_clear.service deleted file mode 100644 index da871007..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_clear.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=runs the mount_manager clear command -Before=shutdown.target - -[Service] -Type=oneshot -ExecStart=/usr/bin/mount_manager clear - -[Install] -WantedBy=shutdown.target \ No newline at end of file diff --git a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove.service b/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove.service deleted file mode 100644 index 1113c67e..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove.service +++ /dev/null @@ -1,3 +0,0 @@ -[Service] -Type=oneshot -ExecStart=/usr/bin/mount_manager remove diff --git a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove_before_octo.service b/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove_before_octo.service deleted file mode 100644 index 019259b9..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/etc/systemd/system/mount_manager_remove_before_octo.service +++ /dev/null @@ -1,10 +0,0 @@ -[Service] -Type=oneshot -ExecStart=/usr/bin/mount_manager remove - -[Unit] -Description=runs mount_manager remove as a tartup process before OctoPrint. -Before=octoprint.service - -[Install] -WantedBy=multi-user.target diff --git a/src/modules/beamos/filesystem/mount_manager/root/usr/share/mount_manager/pubkey.asc b/src/modules/beamos/filesystem/mount_manager/root/usr/share/mount_manager/pubkey.asc deleted file mode 100644 index ed9e6b0d..00000000 --- a/src/modules/beamos/filesystem/mount_manager/root/usr/share/mount_manager/pubkey.asc +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBFkwBHYBCACxVnIexv+XV8Viv6bZ43pPu1BAhIacfNH6BPtoeudkd45V8ag5 -tgoezX80/+U7OPbbAt+AuJks3gm4GDgU0B7m/IF5h4ey36z4DjF0EtQjpQnyMCVj -buZrO4oBlfiCqfvcuH9ylKkGxOpLbSr+3O7HmWUjc9Rfy1o7LdmqInVUPG6qyIOc -iiDDU/sNUmqULUBSkmsGKfNsEsWYlx4rJS3W4EkCslw3VwHDeihzr07T4lUI1d/T -GWE/lBxUv7apkymLH22k0yqhJDOmDesbpeH5xrrR/qPaI7I1tWuKcRB8qcILmBMK -yYKRV0FZHxsHVwW8ETZZk3Suw9PYKG1HBaQzABEBAAG0Q01yIEJlYW0gKEtleSBw -YWlyIGZvciBNckJlYW1zIFVTQiBhdXRvIGV4ZWN1dGlvbikgPGRldkBtci1iZWFt -Lm9yZz6JAU4EEwEIADgWIQS4cmKoAHzh2E5M5W2FBqEr5zvwbQUCWTAEdgIbAwUL -CQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRCFBqEr5zvwbV3aB/wPAzPIK8F58BZA -NRF2ZvXi1AtIJZHrqJsXBemruza607Byb6o6QycSRAdW5RBGg8mBoGDcRqx8IcTc -9+0h0j/CmfUec7nHRA61BXxeBXyN8l6PGG9gZ4Xj/8zcUUGt7YTZllPYdb+ojDai -5eB2t1cWOG8X5E/QOC4ZZWW1R1xBxqgklefpCj/wdykOr3SCuqvSKy5pseoab8J+ -9NHv16g6ZY72h/HMtXSu3kKC/BqoGIpaYXN+cpq2BqfcaIVhRAPkLy6UuuKlAYvt -anZP36kdQpC5ppWwyUJ1VzzLHhjlXkfTkBsTQMerIzjK+QXwKSugOpmdrcZ6JRC3 -JZYy4Bq1uQENBFkwBHYBCADG87xvEvZQ87lLSxut3G6tRvuK773Qj1dVAYpZNDP6 -+wnyOdMAMFNOfkqw/kc4XMb4iW+ufeNTzYIOUVHXVQwg06OeyRCN450BMGNhe2Eo -kNdrkmxEzSKXRgxtC0IoXNoUq9X29yJ56lDWZTmC4NSaJQfbc4mgbAOvZNT3oNI6 -rCfAG89SBOJ5R05iLzNWaN5pFJP7CY3wpYw/OnzuXGxS38wxlaK9xDayqwDgzqAD -8Nd+8qe3MIPPPYyzhG7k6x7mCmrw0mwSxI7lQn8jBl/MkiNpR5O77pc+bPMKOOKM -1QoUK1nJg5t16al2zr2/v1S9/aEw77hBR28g2fj0xj9RABEBAAGJATYEGAEIACAW -IQS4cmKoAHzh2E5M5W2FBqEr5zvwbQUCWTAEdgIbDAAKCRCFBqEr5zvwbfxFCACn -lBoX1Pf2UvZiPpDYgvJpkSW2Ws/icQgwTyoL6bYpowqdaOZObXT63uVp5aSCjMhm -MK2DMI0HMF7kOYWvSfWaGB7UGmv/6HN3OaFxT2oTmINtRVv7eCSa1V9kLFbuWYnB -2Qbk9k4gc6i8cf98bFsmjK5Kk8ZSW3SLR5J8u0wiYmEF+app8v7ArBz63Zm2P/wH -9lZCWHLC+npQh49QG7KSgU/QbxBzT3TMngeYoBOfbqZJtorN3Dpst2f1YbhdxSFW -wgogAomT5SsxPnhAlHq8qXxBOwGxqZ9ONpadbERQKJt88bqnCnbCjMzc7hLW9f5h -09lQLqMPfQmerVOy4Pd/ -=gUJs ------END PGP PUBLIC KEY BLOCK----- diff --git a/src/modules/beamos/filesystem/mrb_check/root/etc/logrotate.d/mrb_check b/src/modules/beamos/filesystem/mrb_check/root/etc/logrotate.d/mrb_check deleted file mode 100644 index 19798fb3..00000000 --- a/src/modules/beamos/filesystem/mrb_check/root/etc/logrotate.d/mrb_check +++ /dev/null @@ -1,12 +0,0 @@ -/var/log/mrb_check.log { - size 5M - rotate 3 - compress - delaycompress - missingok - notifempty - copytruncate - create 644 root root - dateext - dateformat .%Y-%m-%d -} diff --git a/src/modules/beamos/filesystem/mrb_check/root/usr/share/mrb_check.yaml b/src/modules/beamos/filesystem/mrb_check/root/usr/share/mrb_check.yaml deleted file mode 100644 index 580e4a84..00000000 --- a/src/modules/beamos/filesystem/mrb_check/root/usr/share/mrb_check.yaml +++ /dev/null @@ -1,29 +0,0 @@ -env: - env: PROD-S-DC-WATTEROTT -device_info: - type: MrBeam2S - series: 2S - model: MRBEAM2_DC - model_force: MRBEAM2_DC -modules: - - check_0009_i2c - - check_0010_environment - - check_0015_room_environment - - check_0020_leds - - check_0030_iobeam_static - - check_0040_gpg - - check_0045_serial_grbl_programmer - - check_0050_grbl - - check_0060_config_yaml - - check_0070_iobeam_dynamic_auto - - check_0080_iobeam_compressor - - check_0090_iobeam_smart_reedswitches - - check_0110_iobeam_dynamic_manual - - check_0120_movement - - check_0130_laser_temp - - check_0140_save_to_file - - check_0250_calibration_markers -compressor: - required: true -smart_reedswitch: - required: true diff --git a/src/modules/beamos/filesystem/netconnectd/root/etc/logrotate.d/netconnectd b/src/modules/beamos/filesystem/netconnectd/root/etc/logrotate.d/netconnectd deleted file mode 100644 index 8fd9067b..00000000 --- a/src/modules/beamos/filesystem/netconnectd/root/etc/logrotate.d/netconnectd +++ /dev/null @@ -1,11 +0,0 @@ -/var/log/netconnectd.log { - size 2M - rotate 3 - compress - delaycompress - missingok - notifempty - copytruncate - dateext - dateformat .%Y-%m-%d -} diff --git a/src/modules/beamos/filesystem/repos/mount_manager b/src/modules/beamos/filesystem/repos/mount_manager deleted file mode 160000 index b0137a84..00000000 --- a/src/modules/beamos/filesystem/repos/mount_manager +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b0137a84be1438302e0b8837dba09642ea329871 diff --git a/src/modules/beamos/filesystem/repos/mrb_check b/src/modules/beamos/filesystem/repos/mrb_check deleted file mode 160000 index 7139b5ac..00000000 --- a/src/modules/beamos/filesystem/repos/mrb_check +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7139b5ac95cd8fb139e4ca363833d230ff2368a9 diff --git a/src/modules/beamos/filesystem/root/etc/init.d/beamos_first_boot b/src/modules/beamos/filesystem/root/etc/init.d/beamos_first_boot index 3897d880..19596b62 100755 --- a/src/modules/beamos/filesystem/root/etc/init.d/beamos_first_boot +++ b/src/modules/beamos/filesystem/root/etc/init.d/beamos_first_boot @@ -19,34 +19,6 @@ do_start () { REBOOT=false logfile=/var/log/beamos_first_boot.log - BEAMOS_HOSTNAME_BIN=/usr/bin/beamos_hostname - #load current saved vars - SERIAL=$(crudini --get /etc/mrbeam 'Mr Beam' serial 2>/dev/null ) - HOSTNAME=$(crudini --get /etc/mrbeam 'Mr Beam' hostname 2>/dev/null ) - if [ -x $BEAMOS_HOSTNAME_BIN ] && [ -z "$HOSTNAME" ]; then - echo "$(timestamp) Setting the device hostname..." >> $logfile - $BEAMOS_HOSTNAME_BIN >> $logfile - REBOOT=true - fi - BEAMOS_SERIAL_BIN=/usr/bin/beamos_serial - if [ -x $BEAMOS_SERIAL_BIN ] && [ -z "$SERIAL" ]; then - echo "$(timestamp) Setting the Device Serial name..." >> $logfile - $BEAMOS_SERIAL_BIN >> $logfile - fi - - # enable the usb mount manager udev rules - # rm /etc/udev/rules.d/00-mount_manager.rules - - # enable the i2c bus - # Disabled for now - activated during image creation - #sudo raspi-config nonint do_i2c 0 - # enable the uart / hw serial port - # Disabled for now - activated during image creation - #sudo raspi-config nonint do_serial 2 - if $REBOOT; then - echo "$(timestamp) Reboot device to apply changes" >> $logfile - /sbin/reboot - fi } case "$1" in diff --git a/src/modules/beamos/filesystem/root/usr/bin/beamos_hostname b/src/modules/beamos/filesystem/root/usr/bin/beamos_hostname deleted file mode 100755 index 4cc90a12..00000000 --- a/src/modules/beamos/filesystem/root/usr/bin/beamos_hostname +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash - -if [ "$1" = "-h" -o "$1" = "--help" ]; then - echo "Usage: $0 [new-hostname-id]" - echo "Set the machine hostname using\n - 1. The provided hostname ID\n - 2. Use the hostname written in /etc/mrbeam\n - 3. auto generate the hostname as a signature of the RPi device." - echo "Must be run as root." - exit 0 -fi - -. /lib/lsb/init-functions - -# The hostname -CONFIG_HOSTNAME="$(crudini --get /etc/mrbeam 'Mr Beam' hostname 2>/dev/null )" - -if [ -n "$1" ]; then - new_hostname="MrBeam-$1" -elif [ -n "$CONFIG_HOSTNAME" ]; then - new_hostname="$CONFIG_HOSTNAME" -else - # rev allows to use cut for cutting out the last 4 characters. - # And thus making it more POSIX compliant and legacy compatible. - ID=$( - grep Serial /proc/cpuinfo | \ - awk '{print toupper($3)}' | \ - sha1sum | \ - cut -d ' ' -f1 | \ - rev | \ - cut -c -4 | \ - rev | \ - awk '{print toupper($0)}' - ) - [ -z "$ID" ] && log_failure_msg "Failed to generate ID." && exit 1 - new_hostname="MrBeam-$ID" -fi - - -old_hostname="$(hostname)" -# make sure we do have a valid hostname here (see RFC 952 and 1123, a-zA-Z0-9 only) -sanitized_hostname=`echo "$new_hostname" | tr -cd '[[:alnum:]]-'` -if [ "$new_hostname" = "$sanitized_hostname" ]; then - echo "$new_hostname" > /etc/hostname - sed -i -e "s/$old_hostname/$new_hostname/g" /etc/hosts - hostname "$new_hostname" - crudini --set /etc/mrbeam "Mr Beam" hostname $new_hostname - log_success_msg "Host name changed to $new_hostname , reboot to apply..." -else - log_failure_msg "Hostname $new_hostname contains invalid characters (only a-zA-Z0-9 are allowed), refusing to change" - exit 2 -fi diff --git a/src/modules/beamos/filesystem/root/usr/bin/beamos_serial b/src/modules/beamos/filesystem/root/usr/bin/beamos_serial deleted file mode 100755 index d70ffd61..00000000 --- a/src/modules/beamos/filesystem/root/usr/bin/beamos_serial +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -if [ -n "$1" ]; then - echo "Generate the device serial number from the cpu" - echo "serial number and the device series; then" - echo "(over)write it into /etc/mrbeam" - echo " Does not take any arguments." - exit 1 -fi - -SERIES="$(grep device_series /etc/mrbeam | cut -f2 -d '=')" -CPU_SERIAL=$(grep Serial /proc/cpuinfo | awk '{print toupper($3)}') -if [ -n "$SERIES" ]; then - SERIAL=$CPU_SERIAL-$SERIES -else - SERIAL=$CPU_SERIAL -fi -echo "Setting device serial to $SERIAL" - -crudini --set /etc/mrbeam "Mr Beam" serial $SERIAL diff --git a/src/modules/beamos/start_chroot_script b/src/modules/beamos/start_chroot_script index 62888fa7..a3675022 100755 --- a/src/modules/beamos/start_chroot_script +++ b/src/modules/beamos/start_chroot_script @@ -61,7 +61,7 @@ add_mrb3() { apt-get -y install python3 python3-venv python3-dev # create mrb virtual environments # TODO create mrb2 and mrb3 (python 2 and 3 versions) - sudo -u pi python3.7 -m venv /home/pi/mrb3 + sudo -u pi python3.10 -m venv /home/pi/mrb3 } OPRINT=/home/pi/oprint/bin @@ -196,7 +196,6 @@ set_plugin_update_conf_remote() { } # Unpack the regular files -unpack /filesystem/home /home/ pi unpack /filesystem/root / root # Install a more feature-fool alternative to nano : micro @@ -461,7 +460,7 @@ pushd /home/pi # apt-install python3-pip # Install in a separate venv LED_VENV=/usr/local/mrbeam_ledstrips/venv - python3 -m virtualenv -p python3 $LED_VENV + python3.10 -m venv $LED_VENV $LED_VENV/bin/pip install $BEAMOS_RPI_WS281X_ARCHIVE $BEAMOS_MRBEAMLED_ARCHIVE # Link the executables to have mrbeam_ledstrips(_cli) in the $PATH ln -s $LED_VENV/bin/mrbeam_ledstrips /usr/bin/ @@ -527,6 +526,15 @@ if [ -n "$BEAMOS_DEVICE_MODEL" ]; then set_field device_type "MrBeam$BEAMOS_DEVICE_MODEL" /etc/mrbeam fi +######Migration OS stuff##### +# Install bmap-tools for flashing the beamos2 image +sudo apt-get install -y bmap-tools + +pip3 install numpy + +# Copy migrationos.sh and migrationos_to_beamos2.sh to /usr/bin +unpack /filesystem/migration / root +systemctl_if_exists enable migrationos_to_beamos2.service ##################################################################### ### setup systemd units/services @@ -543,3 +551,8 @@ update-rc.d beamos_first_boot defaults # let's remove the configs for system services we don't need # rm /etc/systemd/system/netconnectd.service # fi + +# Dirty fix for reboot issue +line_to_append="gpio=14=ip,pu" +file_path="/boot/config.txt" +sed -i "1i$line_to_append" "$file_path" diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 703d5732..59bac2cd 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -4,7 +4,7 @@ # OctoPrint archive [ -n "$OCTOPI_OCTOPRINT_ARCHIVE" ] || OCTOPI_OCTOPRINT_ARCHIVE=$(wget -q -O - https://api.github.com/repos/foosel/OctoPrint/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) [ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git -[ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes +[ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=no # CuraEngine archive & version [ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 7ca366f8..826e0ffa 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -34,21 +34,55 @@ else fi apt-get -y --force-yes install python3 python3-virtualenv git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libatlas3-base +#apt-get -y install software-properties-common +#add-apt-repository ppa:deadsnakes/ppa +#apt-get update +#apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget +PYTHON3_VERSION=3.10.6 +file="Python-${PYTHON3_VERSION}.tar.xz" +url="https://www.python.org/ftp/python/${PYTHON3_VERSION}/${file}" +apt-get -y install python3-virtualenv git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libatlas3-base +#wget -qO - https://raw.githubusercontent.com/tvdsluijs/sh-python-installer/main/python.sh | sudo bash -s 3.10.0 +echo "Updating & upgrading system" +apt -qq update && apt --yes --force-yes upgrade < /dev/null +echo "Installing Python essentials" +apt -qq install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev < /dev/null +echo "Downloading Python $PYTHON3_VERSION" +wget "${url}" +echo "Decompressing file" +tar -Jxf "${file}" < /dev/null +cd "Python-${PYTHON3_VERSION}" +echo "Prepare the source for the installation" +./configure --enable-optimizations +echo "(Install the new Python version $PYTHON3_VERSION)" +sudo make altinstall +#echo "Let's try to create package" +#sudo cpack +echo "Let's cleanup!" +cd .. +rm -rf "Python-${PYTHON3_VERSION}" +rm -r "${file}" + +echo "Let's install PIP" +apt -qq install -y python3-pip < /dev/null + +#echo "updating pip..." +#python"${py_main_version}" -m pip install --upgrade pip + +new_python_version=$(python -c 'import platform; print(platform.python_version())') +echo "new python version $new_python_version" + +new_python_version=$(python3 -c 'import platform; print(platform.python_version())') +echo "new python version3 $new_python_version" + +new_python_version=$(python3.10 -c 'import platform; print(platform.python_version())') +echo "new python version3.10 $new_python_version" + echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping pushd /home/"${BASE_USER}" - # build virtualenv - sudo -u "${BASE_USER}" python3 -m virtualenv --python=$PYTHON oprint - sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install --upgrade pip - - # OctoPrint - if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] - then - echo "--- Installing OctoPrint" - PIP_DEFAULT_TIMEOUT=60 sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE - fi #mjpg-streamer if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] diff --git a/src/variants/beamos/config b/src/variants/beamos/config index edf5b100..5d4b3e0f 100755 --- a/src/variants/beamos/config +++ b/src/variants/beamos/config @@ -1,9 +1,9 @@ #!/bin/sh # variant mrbeam, flavor default: override hostname & custom config setting -export DIST_NAME=BeamOS -export DIST_VERSION=0.20.3 -export BASE_OVERRIDE_HOSTNAME=MrBeam-XXXX -export BASE_IMAGE_ENLARGEROOT=1700 +export DIST_NAME=MigrationOS +export DIST_VERSION=0.1.0 +export BASE_OVERRIDE_HOSTNAME=MigrationOS +export BASE_IMAGE_ENLARGEROOT=3050 export BEAMOS_DEV=no export MODULES="base(raspicam, network, disable-services(dev-libs(octopi, beamos)))" diff --git a/src/variants/beamos/config.migrationOS b/src/variants/beamos/config.migrationOS new file mode 100644 index 00000000..5a6a21e3 --- /dev/null +++ b/src/variants/beamos/config.migrationOS @@ -0,0 +1,3 @@ +#!/bin/sh +export BEAMOS_DEVICE_MODEL="NONE" +export BEAMOS_MODEL="NONE"