diff --git a/.gitignore b/.gitignore index 62a3d68..1579c56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,176 +1 @@ -# ---> CMake -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps -CMakeUserPresets.json - -# ---> ArchLinuxPackages -*.tar -*.tar.* -*.jar -*.exe -*.msi -*.zip -*.tgz -*.log -*.log.* -*.sig - -pkg/ -src/ - -# ---> C -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - -# ---> VisualStudioCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets - -# Local History for Visual Studio Code -.history/ - -# Built Visual Studio Code Extensions -*.vsix - -# ---> JetBrains -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# AWS User-specific -.idea/**/aws.xml - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# SonarLint plugin -.idea/sonarlint/ - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - +*.log \ No newline at end of file diff --git a/README.md b/README.md index e03661c..c44f0ad 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ -# tailscale-on-flashforge-ad5m +# Tailscale For Adventurer5M +License - Apache Version  - 1.0.0 maintained - yes contributions - welcome +
+Hi, so you must be just as crazy as I am. You found this after all. This is a guide on how to install tailscale on your Adventurer 5M (unsure if it will work on the AD5M Pro). -Project that aims to allow you to put tailscale on and Flashforge Adventurer 5m 3D printer. \ No newline at end of file +
Installation Steps: + +1. Go to the releases tab and get the latest release, its a .zip file don't **download the repository archives**. + +2. Load the zip file onto an empty usb of really any size that will fix it formatted to FAT32 unzip the file so that it is in the root of the usb should look like this: +![folder image](guide-images/guide1.png) + +3. You need to edit the ssh public key! You can open it with notepad/vim/nano and its located in `klipper_mod/root/.ssh/authorized_keys` I have my own key set but you can generate one at [https://showdns.net/ssh-key-generator](https://showdns.net/ssh-key-generator) Or via powershell/bash if you know how to + +4. After you have done that delete the original .zip file and you can then eject your usb and put it in the usb slot of your Flashforge AD5M located near the display. Then just Simply Reboot your printer wait for the install you should see this: +![installing screen](guide-images/guide2.jpg) + +5. When it changes to this: +![installed screen](guide-images/guide3.jpg) +and chimes you can take out the usb and restart the printer + +6. Now you need to connect your device to wifi, if you know how to do this skip to step 9. + +7. First navigate to more![main screen](guide-images/guide4.jpg) +Then to wifi and find your network and sign in ![more screen](guide-images/guide5.jpg) + +8. Grab the wlan ip, its 192.168.0.110 for me keep it for later +![network screen](guide-images/guide6.jpg) + +9. Get an ssh client such as putty, kitty or termius. I will be using termius as it is by far the easiest and most user friendly + +10. Grab that ssh private key you made earlier +![ssh key screenshot](guide-images/guide7.png) + +11. In termius go to keychain and press new key name it whatever and paste that private key into the private key section then when you do that go back to the hosts tab ![termius key creation screenshot](guide-images/image.png) + +12. Make a new host set the ip you saved from the printer earlier into the ip/hostname area set the username to root and select the key you just created as authorization. Then press connect. +![termius host details screenshot](guide-images/image-1.png) + +13. Now you are now connected to ssh +![termius connected to AD5M screenshot](guide-images/image-2.png) + +14. There is only a single command we need to do `tailscale up` and there you go you are all set after you login with the link it gives you + +15. You should see the device in your tailscale now! +![Tailscale screenshot](guide-images/image-3.png) +
+ +## Manual Install (Havent made this yet) +This is more manual than the first option and might be better for you +see [manual install](manual-install.md) for the guide + +## Feature Overview + + +## Optional Features \ No newline at end of file diff --git a/chroot.tar.xz b/chroot.tar.xz new file mode 100644 index 0000000..4a12278 Binary files /dev/null and b/chroot.tar.xz differ diff --git a/flashforge_init.sh b/flashforge_init.sh new file mode 100644 index 0000000..a76cd0d --- /dev/null +++ b/flashforge_init.sh @@ -0,0 +1,99 @@ +#!/bin/sh +set -ex + +# workdir contains our update files +cd "$(dirname "$0")" +WORK_DIR="$(pwd)" +MACHINE=$1 +PID=$2 + +# error handling +error_handler() { + xzcat $WORK_DIR/img/install_fail_error.img.xz > /dev/fb0 + sync + # always exit without error, to prevent immediate boot of flashforge software + exit 0 +} +trap '[ $? -eq 0 ] && exit 0 || error_handler' EXIT + +do_setup() +{ + # safety check, only install on supported printer + if ([ "$MACHINE" != "Adventurer5M" ] && [ "$MACHINE" != "Adventurer5MPro" ]) || \ + ([ "$PID" != "0023" ] && [ "$PID" != "0024" ]) || \ + [ "$(uname -m)" != "armv7l" ] + then + echo "Update file does not match machine type." + xzcat $WORK_DIR/img/install_fail_vers.img.xz > /dev/fb0 + exit 0 + fi + + # saftey check, only install on supported versions + FF_VERSION="$(cat /root/version)" + MIN_VERSION="2.4.5" + if [ "${FF_VERSION//./}" -lt "${MIN_VERSION//./}" ] + then + echo "Printer software version not supported." + xzcat $WORK_DIR/img/install_fail_vers.img.xz > /dev/fb0 + exit 0 + fi + + MOD_INIT_FILE="/etc/init.d/S00klipper_mod" + MOD_INIT_FILE_OLD="/etc/init.d/S90klipper_mod" + MOD_DIR="/data/.klipper_mod" + # chroot is replaced on mod upate or reinstall + # other data in .klipper_mod is kept, unless uninstalled + CHROOT_DIR="${MOD_DIR}/chroot" + + # update start image + xzcat $WORK_DIR/img/install_start.img.xz > /dev/fb0 + # -------------------------------- + + # uninstall previous mod version if present - keep other data in .klipper_mod + rm -f $MOD_INIT_FILE + rm -f $MOD_INIT_FILE_OLD + rm -rf $CHROOT_DIR + + # check free space, we require 512MB before installation for saftey reasons + FREE_SPACE=$(df /data | tail -1 | tr -s ' ' | cut -d' ' -f4) + MIN_SPACE="524228" + if [ "$FREE_SPACE" -lt "$MIN_SPACE" ] + then + echo "Not enough free space on data partition. 512MB required!"; + xzcat $WORK_DIR/img/install_fail_mem.img.xz > /dev/fb0 + exit 0 + fi + + # calculate checksums to be printed in the log + if ls /mnt/Adventurer5M*; then + md5sum /mnt/Adventurer5M* + fi + md5sum $WORK_DIR/chroot.tar.xz + + # unpack chroot environment + mkdir -p $CHROOT_DIR + xz -dc $WORK_DIR/chroot.tar.xz | tar -xf - -C $CHROOT_DIR + sync + + # do intial setup + $CHROOT_DIR/etc/init/S00klipper_mod setup + sync + + # install initfile + cp $CHROOT_DIR/etc/init/S00klipper_mod /etc/init.d/ + sync + + # update end image + # -------------------------------- + xzcat $WORK_DIR/img/install_ok.img.xz > /dev/fb0 +} + +# write log (if mount point is found) +if grep "^/dev/sd[ab12]* /mnt " /proc/mounts; then + do_setup &> /mnt/klipper_mod_install.log + sync +else + do_setup +fi + +exit 0 diff --git a/guide-images/guide1.png b/guide-images/guide1.png new file mode 100644 index 0000000..61ab938 Binary files /dev/null and b/guide-images/guide1.png differ diff --git a/guide-images/guide2.jpg b/guide-images/guide2.jpg new file mode 100644 index 0000000..6ef5c48 Binary files /dev/null and b/guide-images/guide2.jpg differ diff --git a/guide-images/guide3.jpg b/guide-images/guide3.jpg new file mode 100644 index 0000000..acf3ecd Binary files /dev/null and b/guide-images/guide3.jpg differ diff --git a/guide-images/guide4.jpg b/guide-images/guide4.jpg new file mode 100644 index 0000000..10473a5 Binary files /dev/null and b/guide-images/guide4.jpg differ diff --git a/guide-images/guide5.jpg b/guide-images/guide5.jpg new file mode 100644 index 0000000..2480693 Binary files /dev/null and b/guide-images/guide5.jpg differ diff --git a/guide-images/guide6.jpg b/guide-images/guide6.jpg new file mode 100644 index 0000000..cce64ec Binary files /dev/null and b/guide-images/guide6.jpg differ diff --git a/guide-images/guide7.png b/guide-images/guide7.png new file mode 100644 index 0000000..3456a9a Binary files /dev/null and b/guide-images/guide7.png differ diff --git a/guide-images/image-1.png b/guide-images/image-1.png new file mode 100644 index 0000000..287ba24 Binary files /dev/null and b/guide-images/image-1.png differ diff --git a/guide-images/image-2.png b/guide-images/image-2.png new file mode 100644 index 0000000..0f749a6 Binary files /dev/null and b/guide-images/image-2.png differ diff --git a/guide-images/image-3.png b/guide-images/image-3.png new file mode 100644 index 0000000..594bf1c Binary files /dev/null and b/guide-images/image-3.png differ diff --git a/guide-images/image.png b/guide-images/image.png new file mode 100644 index 0000000..2b8cf10 Binary files /dev/null and b/guide-images/image.png differ diff --git a/img/install_fail_error.img.xz b/img/install_fail_error.img.xz new file mode 100644 index 0000000..a33a401 Binary files /dev/null and b/img/install_fail_error.img.xz differ diff --git a/img/install_fail_mem.img.xz b/img/install_fail_mem.img.xz new file mode 100644 index 0000000..ee5571a Binary files /dev/null and b/img/install_fail_mem.img.xz differ diff --git a/img/install_fail_vers.img.xz b/img/install_fail_vers.img.xz new file mode 100644 index 0000000..b5142b3 Binary files /dev/null and b/img/install_fail_vers.img.xz differ diff --git a/img/install_ok.img.xz b/img/install_ok.img.xz new file mode 100644 index 0000000..d5b889a Binary files /dev/null and b/img/install_ok.img.xz differ diff --git a/img/install_start.img.xz b/img/install_start.img.xz new file mode 100644 index 0000000..bf2412c Binary files /dev/null and b/img/install_start.img.xz differ diff --git a/klipper_mod/bin/systemd/tailscale-online.target b/klipper_mod/bin/systemd/tailscale-online.target new file mode 100644 index 0000000..f7d3868 --- /dev/null +++ b/klipper_mod/bin/systemd/tailscale-online.target @@ -0,0 +1,4 @@ +[Unit] +Description=Tailscale is online +Requires=tailscale-wait-online.service +After=tailscale-wait-online.service diff --git a/klipper_mod/bin/systemd/tailscale-wait-online.service b/klipper_mod/bin/systemd/tailscale-wait-online.service new file mode 100644 index 0000000..6b0e249 --- /dev/null +++ b/klipper_mod/bin/systemd/tailscale-wait-online.service @@ -0,0 +1,12 @@ +[Unit] +Description=Wait for Tailscale to be online +After=tailscaled.service +Requires=tailscaled.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/tailscale wait +RemainAfterExit=yes + +[Install] +WantedBy=tailscale-online.target diff --git a/klipper_mod/bin/systemd/tailscaled.defaults b/klipper_mod/bin/systemd/tailscaled.defaults new file mode 100644 index 0000000..75f1c3e --- /dev/null +++ b/klipper_mod/bin/systemd/tailscaled.defaults @@ -0,0 +1,8 @@ +# Set the port to listen on for incoming VPN packets. +# Remote nodes will automatically be informed about the new port number, +# but you might want to configure this in order to set external firewall +# settings. +PORT="41641" + +# Extra flags you might want to pass to tailscaled. +FLAGS="" diff --git a/klipper_mod/bin/systemd/tailscaled.service b/klipper_mod/bin/systemd/tailscaled.service new file mode 100644 index 0000000..81490c4 --- /dev/null +++ b/klipper_mod/bin/systemd/tailscaled.service @@ -0,0 +1,23 @@ +[Unit] +Description=Tailscale node agent +Documentation=https://tailscale.com/docs/ +Wants=network-pre.target +After=network-pre.target NetworkManager.service systemd-resolved.service + +[Service] +EnvironmentFile=/etc/default/tailscaled +ExecStart=/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port=${PORT} $FLAGS +ExecStopPost=/usr/sbin/tailscaled --cleanup + +Restart=on-failure + +RuntimeDirectory=tailscale +RuntimeDirectoryMode=0755 +StateDirectory=tailscale +StateDirectoryMode=0700 +CacheDirectory=tailscale +CacheDirectoryMode=0750 +Type=notify + +[Install] +WantedBy=multi-user.target diff --git a/klipper_mod/bin/tailscale b/klipper_mod/bin/tailscale new file mode 100644 index 0000000..ef29636 Binary files /dev/null and b/klipper_mod/bin/tailscale differ diff --git a/klipper_mod/bin/tailscaled b/klipper_mod/bin/tailscaled new file mode 100644 index 0000000..05e8b25 Binary files /dev/null and b/klipper_mod/bin/tailscaled differ diff --git a/klipper_mod/etc/init.d/S99tailscale b/klipper_mod/etc/init.d/S99tailscale new file mode 100644 index 0000000..9c66863 --- /dev/null +++ b/klipper_mod/etc/init.d/S99tailscale @@ -0,0 +1,23 @@ +#!/bin/sh + +case "$1" in + start) + echo "Starting tailscaled..." + tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock --tun=userspace-networking > /dev/null 2>&1 & + ;; + stop) + echo "Stopping tailscaled..." + killall tailscaled + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/klipper_mod/root/.ssh/authorized_keys b/klipper_mod/root/.ssh/authorized_keys new file mode 100644 index 0000000..d226632 --- /dev/null +++ b/klipper_mod/root/.ssh/authorized_keys @@ -0,0 +1,4 @@ +# This is my ssh key you can change this you will need ssh access +# Use this if you don't know how to make one https://showdns.net/ssh-key-generator +# Put the public key here +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM9JE+YM5NO3RSLh9B0Q9PLny8VdC/TrS5R50aZpDEvu \ No newline at end of file diff --git a/klipper_mod/root/README.md b/klipper_mod/root/README.md new file mode 100644 index 0000000..473a0f4 diff --git a/manual-install.md b/manual-install.md new file mode 100644 index 0000000..473a0f4