From 5854ab7c619b3c01446951f925c5f27eb37ed077 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 2 Apr 2022 23:41:49 -0400 Subject: [PATCH 1/8] /usr/bin/iiab-remoteit to quickly obtain a new claim code --- roles/remoteit/README.md | 30 +++++++++------ roles/remoteit/defaults/main.yml | 42 ++++++++++----------- roles/remoteit/tasks/install.yml | 27 ++++++++++---- roles/remoteit/templates/iiab-remoteit | 51 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 40 deletions(-) create mode 100755 roles/remoteit/templates/iiab-remoteit diff --git a/roles/remoteit/README.md b/roles/remoteit/README.md index f6e657d03..a34613b9b 100644 --- a/roles/remoteit/README.md +++ b/roles/remoteit/README.md @@ -18,11 +18,15 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag ### Install remote.it onto an IIAB + register it + authorize services/ports -1. Set `remoteit_install` and `remoteit_enabled` to `True` in your IIAB's [/etc/iiab/local_vars.yml](http://wiki.laptop.org/go/IIAB/FAQ#What_is_local_vars.yml_and_how_do_I_customize_it.3F) +1. Connect your IIAB device to the Internet. - (If possible, do that prior to [installing IIAB](https://download.iiab.io/), then install IIAB using `sudo iiab`, and when that's complete go directly to Step 3. below.) +2. If your IIAB software is already installed, run `sudo iiab-remoteit` then skip to Step 5. below. -2. Make sure your IIAB is connected to the Internet. +3. If your IIAB software isn't yet installed, set `remoteit_install` and `remoteit_enabled` to `True` in its [/etc/iiab/local_vars.yml](https://wiki.iiab.io/go/FAQ#What_is_local_vars.yml_and_how_do_I_customize_it.3F). + + Install [IIAB software](https://download.iiab.io/) e.g. by running `sudo iiab` then follow any on-screen instructions — until "INTERNET-IN-A-BOX (IIAB) SOFTWARE INSTALL IS COMPLETE" eventually appears on screen. + + - (While rarely needed, both above also install the _optional_ `/usr/bin/remoteit` [command-line interface (CLI)](https://docs.remote.it/software/cli), which offers [a few more features](https://support.remote.it/hc/en-us/articles/4412786750861-Install-the-remoteit-agent-on-your-device) than the Device Package.) + (This installs and enables the remote.it [Device Package](https://docs.remote.it/software/device-package) for your CPU and OS. This approach also installs the _optional_ `/usr/bin/remoteit` [command-line interface (CLI)](https://docs.remote.it/software/cli), which offers [a few more features](https://support.remote.it/hc/en-us/articles/4412786750861-Install-the-remoteit-agent-on-your-device) than the Device Package.) - - -3. To obtain your IIAB's 8-character remote.it claim code (allowing you to make a remote connection to this IIAB device) run: +4. To obtain your IIAB's 8-character remote.it claim code (allowing you to make a remote connection to this IIAB device) run: ``` sudo grep claim /etc/remoteit/config.json @@ -50,7 +52,7 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag *The claim code must be used within 24 hours, per:* https://docs.remote.it/device-package/installation#2.-update-your-package-manager-and-install - _If your claim code has expired, please reinstall the latest remote.it (in Step 2. above!)_ + _If your claim code has expired, please run `sudo iiab-remoteit` just as in Step 2._ -4. Submit the claim code at https://remote.it (log into the Web Portal), or within the remote.it desktop application if you installed that on your own laptop/computer. +5. Submit the claim code at https://remote.it (log into their Web Portal), or within the remote.it [desktop application](https://remote.it/download/) on your own laptop/computer. Either way, click on the '+' icon to enter the remote.it claim code (to register the IIAB device to your account) as shown in this screenshot: https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device -5. Authorize services/ports (e.g. SSH, HTTP, etc) for your IIAB device, as shown in these screenshots: https://docs.remote.it/software/device-package/installation#4.-set-up-services-on-your-device +6. Authorize services/ports (e.g. SSH, HTTP, etc) for your IIAB device, as shown in these screenshots: https://docs.remote.it/software/device-package/installation#4.-set-up-services-on-your-device SUMMARY: One or more remote.it "Services" need to be authorized (registered) to allow remote access to your IIAB device: https://support.remote.it/hc/en-us/articles/360060992631-Services EXAMPLES: SSH (port 22) and/or HTTP (port 80): https://support.remote.it/hc/en-us/articles/360058603991-Configuring-remoteit-Services-on-devices-with-remote-it-Desktop +### How to I disable remote.it on my IIAB? + +1. Run `sudo nano /etc/iiab/local_vars.yml` to set `remoteit_enabled: False` + +2. Run `cd /opt/iiab/iiab` and then `sudo ./runrole remoteit` + ## Docs diff --git a/roles/remoteit/defaults/main.yml b/roles/remoteit/defaults/main.yml index d57b64887..e4ea3fc46 100644 --- a/roles/remoteit/defaults/main.yml +++ b/roles/remoteit/defaults/main.yml @@ -7,29 +7,29 @@ # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! -# 2022-03-31: https://remote.it/download/ offers 4 relevant "Device Packages" -# 1) Raspberry Pi (ARM) = armhf.rpi -# 2) Raspberry Pi (ARM64) = arm64.rpi -# 3) Debian Linux (ARM64) = arm64 -# 4) Debian Linux (x86_64) = amd64 +# # 2022-03-31: https://remote.it/download/ offers 4 relevant "Device Packages" +# # 1) Raspberry Pi (ARM) = armhf.rpi +# # 2) Raspberry Pi (ARM64) = arm64.rpi +# # 3) Debian Linux (ARM64) = arm64 +# # 4) Debian Linux (x86_64) = amd64 -# See https://docs.remote.it/software/device-package/installation to refine URL below: -device_suffixes: - armv6: armhf.rpi - armv6l: armhf.rpi - armv7: armhf.rpi - armv7l: armhf.rpi - armv8: arm64.rpi - aarch64: arm64 - x86_64: amd64 -remoteit_device_suffix: "{{ device_suffixes[ansible_architecture] | default('unknown') }}" -remoteit_device_url: https://downloads.remote.it/remoteit/latest/remoteit.{{ remoteit_device_suffix }}.deb +# # See https://docs.remote.it/software/device-package/installation to refine URL below: +# device_suffixes: +# armv6: armhf.rpi +# armv6l: armhf.rpi +# armv7: armhf.rpi +# armv7l: armhf.rpi +# armv8: arm64.rpi +# aarch64: arm64 +# x86_64: amd64 +# remoteit_device_suffix: "{{ device_suffixes[ansible_architecture] | default('unknown') }}" +# remoteit_device_url: https://downloads.remote.it/remoteit/latest/remoteit.{{ remoteit_device_suffix }}.deb -# 2022-03-31: Use "latest" above, instead of ever-changing version below -# remoteit_version: 4.14.1 -# remoteit_deb: remoteit-{{ remoteit_version }}.{{ remoteit_device_suffix }}.deb -# remoteit_device_url: https://downloads.remote.it/remoteit/v{{ remoteit_version }}/{{ remoteit_deb }} -# # Example... https://downloads.remote.it/remoteit/v4.14.1/remoteit-4.14.1.armhf.rpi.deb +# # 2022-03-31: Use "latest" above, instead of ever-changing version below +# # remoteit_version: 4.14.1 +# # remoteit_deb: remoteit-{{ remoteit_version }}.{{ remoteit_device_suffix }}.deb +# # remoteit_device_url: https://downloads.remote.it/remoteit/v{{ remoteit_version }}/{{ remoteit_deb }} +# # # Example... https://downloads.remote.it/remoteit/v4.14.1/remoteit-4.14.1.armhf.rpi.deb # 2022-03-31: https://remote.it/download/ offers 4 relevant "CLI" installs: diff --git a/roles/remoteit/tasks/install.yml b/roles/remoteit/tasks/install.yml index 7e1190a18..557a963a1 100644 --- a/roles/remoteit/tasks/install.yml +++ b/roles/remoteit/tasks/install.yml @@ -1,7 +1,7 @@ -- name: Fail if architecture remoteit_device_suffix == "unknown" - fail: - msg: "Could not find a remote.it Device Package (.deb) for CPU architecture \"{{ ansible_architecture }}\"" - when: remoteit_device_suffix == "unknown" +# - name: Fail if architecture remoteit_device_suffix == "unknown" +# fail: +# msg: "Could not find a remote.it Device Package (.deb) for CPU architecture \"{{ ansible_architecture }}\"" +# when: remoteit_device_suffix == "unknown" # - name: mkdir {{ downloads_dir }} # As roles/2-common/tasks/fl.yml has not run yet # file: @@ -15,19 +15,30 @@ # force: yes # timeout: "{{ download_timeout }}" -- name: Uninstall previously installed 'remoteit*' Device Package(s) +- name: Purge previously installed 'remoteit*' Device Package(s) apt: name: remoteit* state: absent + purge: yes ignore_errors: yes # - name: "Install Device Package: {{ downloads_dir }}/{{ remoteit_deb }}" # apt: # deb: "{{ downloads_dir }}/{{ remoteit_deb }}" -- name: "Install Device Package: {{ remoteit_device_url }}" - apt: - deb: "{{ remoteit_device_url }}" +# - name: "Install Device Package: {{ remoteit_device_url }}" +# apt: +# deb: "{{ remoteit_device_url }}" + +- name: Install remote.it Device Package for your CPU/OS, using https://downloads.remote.it/remoteit/install_agent.sh + shell: curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh + + +- name: "Install from template /usr/bin/iiab-remoteit to quickly obtain a new remote.it claim code, if later nec (much like the above 2 steps)" + template: + src: iiab-remoteit + dest: /usr/bin + mode: 0755 - name: Fail if architecture remoteit_cli_suffix == "unknown" diff --git a/roles/remoteit/templates/iiab-remoteit b/roles/remoteit/templates/iiab-remoteit new file mode 100755 index 000000000..79163e81a --- /dev/null +++ b/roles/remoteit/templates/iiab-remoteit @@ -0,0 +1,51 @@ +#!/bin/bash -e + +# Run 'sudo iiab-remoteit' to (re)install & enable remote.it -- GENERAL TIPS: +# http://FAQ.IIAB.IO -> "How can I remotely manage my Internet-in-a-Box?" + +# /usr/bin/remoteit CLI is already be installed by: +# https://github.com/iiab/iiab/blob/master/roles/remoteit/tasks/install.yml + +echo -e "\nhttps://remote.it can help you remotely manage this IIAB:" +echo -e "https://github.com/iiab/iiab/blob/master/roles/remoteit/README.md\n" + +echo -en "\e[1mInstall remote.it Device Package after purging all prior versions? [Y/n]\e[0m " +read ans < /dev/tty # Strips outer whitespace, whether we like it or not! +echo +[ "$ans" = "n" ] || [ "$ans" = "N" ] && exit 1 + +if grep -q '^remoteit_install:' /etc/iiab/local_vars.yml; then + sed -i "s/^remoteit_install:.*/remoteit_install: True/" /etc/iiab/local_vars.yml +else + echo "remoteit_install: True" >> /etc/iiab/local_vars.yml +fi + +if grep -q '^remoteit_enabled:' /etc/iiab/local_vars.yml; then + sed -i "s/^remoteit_enabled:.*/remoteit_enabled: True/" /etc/iiab/local_vars.yml +else + echo "remoteit_enabled: True" >> /etc/iiab/local_vars.yml +fi + +# 2022-04-02: Full Path Avoids problematic /usr/local/bin/apt on Linux Mint +/usr/bin/apt -y purge remoteit* + +# Why the brutal purge? Even 'apt -y reinstall remoteit.*.deb' is much stronger +# than 'install -y' in install_agent.sh below, but still insufficient. Maybe in +# future years their /usr/bin/remoteit CLI might seed a new claim code when nec? + +# apt install & enable "latest" remote.it Device Package for your CPU/OS +curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh + +if grep -q '^remoteit_installed:' /etc/iiab/iiab_state.yml; then + sed -i "s/^remoteit_installed:.*/remoteit_installed: True/" /etc/iiab/iiab_state.yml +else + echo "remoteit_installed: True" >> /etc/iiab/iiab_state.yml +fi + +echo -e "\e[44;1mNEXT STEPS...\e[0m\n" + +echo -e "\e[1m1) Install the remote.it Desktop Application on your own laptop/computer:" +echo -e " https://remote.it/download/\n" + +echo -e "2) Use the above 8-character claim code within 24h as shown here:" +echo -e " https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device\e[0m\n" From 4111837fbd8054c2920ad30fbecd163c3a364eee Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 3 Apr 2022 00:18:32 -0400 Subject: [PATCH 2/8] Polish introductory doc remoteit/README.md --- roles/remoteit/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/roles/remoteit/README.md b/roles/remoteit/README.md index a34613b9b..7e9ad2c47 100644 --- a/roles/remoteit/README.md +++ b/roles/remoteit/README.md @@ -12,7 +12,7 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag 1. Browse to [https://remote.it](https://remote.it) (Web Portal) and sign up for an account. -2. Download the [remote.it desktop application](https://remote.it/download/) e.g. for Windows, macOS or Linux to your own laptop/computer — if you prefer this over the https://remote.it Web Portal and its [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages). +2. Download the [remote.it desktop application](https://remote.it/download/) (e.g. for Windows, macOS or Linux) to your own laptop/computer — if you prefer this over the https://remote.it Web Portal and its [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages). COMPARISON: "The Desktop and [CLI](https://docs.remote.it/software/cli) can [each] support both peer to peer connections and proxy connections [whereas] the Web Portal and API can only support proxy connections" according to https://docs.remote.it/software/device-package/usage @@ -22,7 +22,7 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag 2. If your IIAB software is already installed, run `sudo iiab-remoteit` then skip to Step 5. below. -3. If your IIAB software isn't yet installed, set `remoteit_install` and `remoteit_enabled` to `True` in its [/etc/iiab/local_vars.yml](https://wiki.iiab.io/go/FAQ#What_is_local_vars.yml_and_how_do_I_customize_it.3F). +3. If your IIAB software isn't yet installed, set `remoteit_install` and `remoteit_enabled` to `True` in its [/etc/iiab/local_vars.yml](https://wiki.iiab.io/go/FAQ#What_is_local_vars.yml_and_how_do_I_customize_it.3F) Install [IIAB software](https://download.iiab.io/) e.g. by running `sudo iiab` then follow any on-screen instructions — until "INTERNET-IN-A-BOX (IIAB) SOFTWARE INSTALL IS COMPLETE" eventually appears on screen. @@ -42,7 +42,7 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag sudo ./runrole --reinstall remoteit ``` --> - (This installs and enables the remote.it [Device Package](https://docs.remote.it/software/device-package) for your CPU and OS. This approach also installs the _optional_ `/usr/bin/remoteit` [command-line interface (CLI)](https://docs.remote.it/software/cli), which offers [a few more features](https://support.remote.it/hc/en-us/articles/4412786750861-Install-the-remoteit-agent-on-your-device) than the Device Package.) + (This installs and enables the remote.it [Device Package](https://docs.remote.it/software/device-package) for your CPU and OS. This also installs the _optional_ `/usr/bin/remoteit` [command-line interface (CLI)](https://docs.remote.it/software/cli), which offers [a few more features](https://support.remote.it/hc/en-us/articles/4412786750861-Install-the-remoteit-agent-on-your-device) than the Device Package.) 4. To obtain your IIAB's 8-character remote.it claim code (allowing you to make a remote connection to this IIAB device) run: @@ -52,7 +52,7 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag *The claim code must be used within 24 hours, per:* https://docs.remote.it/device-package/installation#2.-update-your-package-manager-and-install - _If your claim code has expired, please run `sudo iiab-remoteit` just as in Step 2._ + _If your claim code has expired, please run_ `sudo iiab-remoteit` _just as in Step 2._ -5. Submit the claim code at https://remote.it (log into their Web Portal), or within the remote.it [desktop application](https://remote.it/download/) on your own laptop/computer. +5. Submit the claim code within the remote.it [desktop application](https://remote.it/download/) on your own laptop/computer. Or if you prefer, do that by logging into their Web Portal at https://remote.it Either way, click on the '+' icon to enter the remote.it claim code (to register the IIAB device to your account) as shown in this screenshot: https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device @@ -74,7 +74,12 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag 1. Run `sudo nano /etc/iiab/local_vars.yml` to set `remoteit_enabled: False` -2. Run `cd /opt/iiab/iiab` and then `sudo ./runrole remoteit` +2. Then run: + + ``` + cd /opt/iiab/iiab + sudo ./runrole remoteit + ``` ## Docs From a77b95af20ee8a5670ab6b8535316eff1f78db48 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Apr 2022 00:57:47 -0400 Subject: [PATCH 3/8] remoteit/tasks/enable-or-disable.yml: 'schannel' systemd ON/OFF, like 'connectd' --- roles/remoteit/tasks/enable-or-disable.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/roles/remoteit/tasks/enable-or-disable.yml b/roles/remoteit/tasks/enable-or-disable.yml index 2e1ddb36f..a29f26090 100644 --- a/roles/remoteit/tasks/enable-or-disable.yml +++ b/roles/remoteit/tasks/enable-or-disable.yml @@ -1,17 +1,23 @@ -- name: Enable & (Re)Start remote.it's connectd daemon which calls home +- name: Enable & (Re)Start remote.it's daemons {connectd, schannel} systemd: - name: connectd + name: "{{ item }}" daemon_reload: yes enabled: yes state: restarted + with_items: + - connectd + - schannel when: remoteit_enabled -- name: Disable & Stop remote.it's connectd daemon +- name: Disable & Stop remote.it's daemons {connectd, schannel} systemd: - name: connectd + name: "{{ item }}" enabled: no state: stopped + with_items: + - connectd + - schannel when: not remoteit_enabled - name: Identify remoteit service (connector) unit file name, including uuid From a40183fd2e45af79220cb447fa45aaaa3ff0985a Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Apr 2022 21:57:23 -0400 Subject: [PATCH 4/8] Fast /usr/bin/iiab-remoteit generates new claim code + optionally upgrades --- roles/remoteit/README.md | 38 +++++++++--- roles/remoteit/tasks/install.yml | 4 +- roles/remoteit/templates/iiab-remoteit | 70 +++++++++++++--------- roles/remoteit/templates/iiab-remoteit.old | 51 ++++++++++++++++ 4 files changed, 126 insertions(+), 37 deletions(-) create mode 100755 roles/remoteit/templates/iiab-remoteit.old diff --git a/roles/remoteit/README.md b/roles/remoteit/README.md index 7e9ad2c47..dbaa5251d 100644 --- a/roles/remoteit/README.md +++ b/roles/remoteit/README.md @@ -8,16 +8,26 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag ## Getting Started -### Create a remote.it account + consider its desktop application +### Create a remote.it account + install its desktop application 1. Browse to [https://remote.it](https://remote.it) (Web Portal) and sign up for an account. -2. Download the [remote.it desktop application](https://remote.it/download/) (e.g. for Windows, macOS or Linux) to your own laptop/computer — if you prefer this over the https://remote.it Web Portal and its [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages). +2. Download and install the remote.it [desktop application](https://remote.it/download/) (e.g. for Windows, macOS or Linux) on your own laptop/computer. Their https://remote.it Web Portal and [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages) are also sometimes possible, but less functional. COMPARISON: "The Desktop and [CLI](https://docs.remote.it/software/cli) can [each] support both peer to peer connections and proxy connections [whereas] the Web Portal and API can only support proxy connections" according to https://docs.remote.it/software/device-package/usage -### Install remote.it onto an IIAB + register it + authorize services/ports + +### Generate a remote.it claim code for your IIAB + register it + authorize services/ports +Prerequisite: Find an IIAB with `remoteit_installed: True` in `/etc/iiab/iiab_state.yml`. + +1. Run `sudo iiab-remoteit` + + Hit `[Enter]` twice if you want to quickly generate a new claim code for your IIAB. + + The claim code is stored in `/etc/remoteit/config.json` and must be used [within 24 hours](https://docs.remote.it/device-package/installation#2.-update-your-package-manager-and-install). + + - (This installs and enables the remote.it [Device Package](https://docs.remote.it/software/device-package) for your CPU and OS. This also installs the _optional_ `/usr/bin/remoteit` [command-line interface (CLI)](https://docs.remote.it/software/cli), which offers [a few more features](https://support.remote.it/hc/en-us/articles/4412786750861-Install-the-remoteit-agent-on-your-device) than the Device Package.) + -5. Submit the claim code within the remote.it [desktop application](https://remote.it/download/) on your own laptop/computer. Or if you prefer, do that by logging into their Web Portal at https://remote.it +2. Submit the claim code within the remote.it [desktop application](https://remote.it/download/) on your own laptop/computer. Or if you prefer, do that by logging into their Web Portal at: https://remote.it - Either way, click on the '+' icon to enter the remote.it claim code (to register the IIAB device to your account) as shown in this screenshot: https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device + Either way, click on the '+' icon to enter the remote.it claim code (to register the IIAB device to your account) as shown in this [screenshot](https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device). -6. Authorize services/ports (e.g. SSH, HTTP, etc) for your IIAB device, as shown in these screenshots: https://docs.remote.it/software/device-package/installation#4.-set-up-services-on-your-device +3. Authorize services/ports (e.g. SSH, HTTP, etc) for your IIAB device, as shown in these [screenshots](https://docs.remote.it/software/device-package/installation#4.-set-up-services-on-your-device). - SUMMARY: One or more remote.it "Services" need to be authorized (registered) to allow remote access to your IIAB device: https://support.remote.it/hc/en-us/articles/360060992631-Services + SUMMARY: One or more remote.it "Services" need to be authorized (registered) to allow remote access to your IIAB device:
https://support.remote.it/hc/en-us/articles/360060992631-Services - EXAMPLES: SSH (port 22) and/or HTTP (port 80): https://support.remote.it/hc/en-us/articles/360058603991-Configuring-remoteit-Services-on-devices-with-remote-it-Desktop + EXAMPLES: SSH (port 22) and/or HTTP (port 80):
https://support.remote.it/hc/en-us/articles/360058603991-Configuring-remoteit-Services-on-devices-with-remote-it-Desktop ### How to I disable remote.it on my IIAB? @@ -81,6 +94,13 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag sudo ./runrole remoteit ``` +3. If want to completely remove the remote.it software and its settings, also run: + + ``` + sudo apt purge "remoteit*" + sudo rm /usr/bin/remoteit + ``` + ## Docs diff --git a/roles/remoteit/tasks/install.yml b/roles/remoteit/tasks/install.yml index 557a963a1..88ca82640 100644 --- a/roles/remoteit/tasks/install.yml +++ b/roles/remoteit/tasks/install.yml @@ -15,6 +15,8 @@ # force: yes # timeout: "{{ download_timeout }}" +# 2022-04-03: Unfort still necessary, as their install_agent.sh below uses apt +# with 'install -y' instead of '-y reinstall' or '-y --reinstall install' - name: Purge previously installed 'remoteit*' Device Package(s) apt: name: remoteit* @@ -34,7 +36,7 @@ shell: curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh -- name: "Install from template /usr/bin/iiab-remoteit to quickly obtain a new remote.it claim code, if later nec (much like the above 2 steps)" +- name: "Install /usr/bin/iiab-remoteit from template -- so IIAB operators can quickly generate a new remote.it claim code (in /etc/remoteit/config.json) AND enable remoteit's 3 systemd services -- optionally downloading + installing the very latest Device Package (like the 2 steps above)" template: src: iiab-remoteit dest: /usr/bin diff --git a/roles/remoteit/templates/iiab-remoteit b/roles/remoteit/templates/iiab-remoteit index 79163e81a..ee346d070 100755 --- a/roles/remoteit/templates/iiab-remoteit +++ b/roles/remoteit/templates/iiab-remoteit @@ -3,21 +3,52 @@ # Run 'sudo iiab-remoteit' to (re)install & enable remote.it -- GENERAL TIPS: # http://FAQ.IIAB.IO -> "How can I remotely manage my Internet-in-a-Box?" -# /usr/bin/remoteit CLI is already be installed by: +# 'remoteit' Device Package AND /usr/bin/remoteit CLI already installed by: # https://github.com/iiab/iiab/blob/master/roles/remoteit/tasks/install.yml -echo -e "\nhttps://remote.it can help you remotely manage this IIAB:" +# 2022-04-03: SEE ALSO roles/remoteit/templates/iiab-remote.old + +echo -e "\nhttps://remote.it can help you remotely manage this IIAB. Summary:\n" + echo -e "https://github.com/iiab/iiab/blob/master/roles/remoteit/README.md\n" -echo -en "\e[1mInstall remote.it Device Package after purging all prior versions? [Y/n]\e[0m " +echo -en "\e[1mTo proceed we will delete /etc/remoteit/config.json, Ok? [Y/n]\e[0m " read ans < /dev/tty # Strips outer whitespace, whether we like it or not! echo -[ "$ans" = "n" ] || [ "$ans" = "N" ] && exit 1 +[[ $ans = "n" ]] || [[ $ans = "N" ]] && exit 1 -if grep -q '^remoteit_install:' /etc/iiab/local_vars.yml; then - sed -i "s/^remoteit_install:.*/remoteit_install: True/" /etc/iiab/local_vars.yml +echo -e "\nThis IIAB must be online to begin!\n" + +echo -en "\e[1mOptionally download + install latest remote.it Device Package? [y/N]\e[0m " +read ans < /dev/tty # Strips outer whitespace, whether we like it or not! +echo + +if [[ $ans = "y" ]] || [[ $ans = "Y" ]]; then + # 2022-04-02: Full Path Avoids problematic /usr/local/bin/apt on Linux Mint + /usr/bin/apt -y purge "remoteit*" || true + + # Why the brutal purge? Even 'apt -y reinstall remoteit.*.deb' is stronger + # than 'install -y' in install_agent.sh, but still sometimes insufficient! + + # apt install & enable "latest" remote.it Device Package for your CPU/OS + curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh else - echo "remoteit_install: True" >> /etc/iiab/local_vars.yml + # '|| true' overrides 'bash -e' so script continues if config.json missing + mv /etc/remoteit/config.json /etc/remoteit/config.json.$(date +%F_%T_%Z) || true + + echo -e "In just a few seconds, all 3 services should be enabled + started.\n" + + systemctl restart connectd # Claim Code logic + kickstarts 2 svcs below + systemctl enable connectd # 3 enable lines, like enable-or-disable.yml + + # "Remote tcp command service" started above + systemctl enable schannel # 3 enable lines, like enable-or-disable.yml + + # "Remote tcp connection service" appears a few seconds after connectd is + # started above. It's also auto-enabled by above, so this may be overkill: + systemctl enable $(ls /etc/systemd/system/multi-user.target.wants/ | grep remoteit@) # 3 enable lines, like enable-or-disable.yml + # Its systemd service name (e.g. remoteit@80:00:01:7F:7E:00:56:36.service) + # changes when a new claim code is generated. fi if grep -q '^remoteit_enabled:' /etc/iiab/local_vars.yml; then @@ -26,26 +57,11 @@ else echo "remoteit_enabled: True" >> /etc/iiab/local_vars.yml fi -# 2022-04-02: Full Path Avoids problematic /usr/local/bin/apt on Linux Mint -/usr/bin/apt -y purge remoteit* +claim_code=$(grep claim /etc/remoteit/config.json | rev | cut -d\" -f2 | rev) +echo -e "\nYour new claim code is \e[44;1m${claim_code}\e[0m -- YOUR NEXT STEPS ARE...\n" -# Why the brutal purge? Even 'apt -y reinstall remoteit.*.deb' is much stronger -# than 'install -y' in install_agent.sh below, but still insufficient. Maybe in -# future years their /usr/bin/remoteit CLI might seed a new claim code when nec? - -# apt install & enable "latest" remote.it Device Package for your CPU/OS -curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh - -if grep -q '^remoteit_installed:' /etc/iiab/iiab_state.yml; then - sed -i "s/^remoteit_installed:.*/remoteit_installed: True/" /etc/iiab/iiab_state.yml -else - echo "remoteit_installed: True" >> /etc/iiab/iiab_state.yml -fi - -echo -e "\e[44;1mNEXT STEPS...\e[0m\n" - -echo -e "\e[1m1) Install the remote.it Desktop Application on your own laptop/computer:" +echo -e "\e[1m1) Install the remote.it Desktop Application on your own laptop/computer:\e[0m" echo -e " https://remote.it/download/\n" -echo -e "2) Use the above 8-character claim code within 24h as shown here:" -echo -e " https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device\e[0m\n" +echo -e "\e[1m2) Use the above 8-character claim code WITHIN 24H as shown here:\e[0m" +echo -e " https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device\n" diff --git a/roles/remoteit/templates/iiab-remoteit.old b/roles/remoteit/templates/iiab-remoteit.old new file mode 100755 index 000000000..79163e81a --- /dev/null +++ b/roles/remoteit/templates/iiab-remoteit.old @@ -0,0 +1,51 @@ +#!/bin/bash -e + +# Run 'sudo iiab-remoteit' to (re)install & enable remote.it -- GENERAL TIPS: +# http://FAQ.IIAB.IO -> "How can I remotely manage my Internet-in-a-Box?" + +# /usr/bin/remoteit CLI is already be installed by: +# https://github.com/iiab/iiab/blob/master/roles/remoteit/tasks/install.yml + +echo -e "\nhttps://remote.it can help you remotely manage this IIAB:" +echo -e "https://github.com/iiab/iiab/blob/master/roles/remoteit/README.md\n" + +echo -en "\e[1mInstall remote.it Device Package after purging all prior versions? [Y/n]\e[0m " +read ans < /dev/tty # Strips outer whitespace, whether we like it or not! +echo +[ "$ans" = "n" ] || [ "$ans" = "N" ] && exit 1 + +if grep -q '^remoteit_install:' /etc/iiab/local_vars.yml; then + sed -i "s/^remoteit_install:.*/remoteit_install: True/" /etc/iiab/local_vars.yml +else + echo "remoteit_install: True" >> /etc/iiab/local_vars.yml +fi + +if grep -q '^remoteit_enabled:' /etc/iiab/local_vars.yml; then + sed -i "s/^remoteit_enabled:.*/remoteit_enabled: True/" /etc/iiab/local_vars.yml +else + echo "remoteit_enabled: True" >> /etc/iiab/local_vars.yml +fi + +# 2022-04-02: Full Path Avoids problematic /usr/local/bin/apt on Linux Mint +/usr/bin/apt -y purge remoteit* + +# Why the brutal purge? Even 'apt -y reinstall remoteit.*.deb' is much stronger +# than 'install -y' in install_agent.sh below, but still insufficient. Maybe in +# future years their /usr/bin/remoteit CLI might seed a new claim code when nec? + +# apt install & enable "latest" remote.it Device Package for your CPU/OS +curl -L https://downloads.remote.it/remoteit/install_agent.sh | sh + +if grep -q '^remoteit_installed:' /etc/iiab/iiab_state.yml; then + sed -i "s/^remoteit_installed:.*/remoteit_installed: True/" /etc/iiab/iiab_state.yml +else + echo "remoteit_installed: True" >> /etc/iiab/iiab_state.yml +fi + +echo -e "\e[44;1mNEXT STEPS...\e[0m\n" + +echo -e "\e[1m1) Install the remote.it Desktop Application on your own laptop/computer:" +echo -e " https://remote.it/download/\n" + +echo -e "2) Use the above 8-character claim code within 24h as shown here:" +echo -e " https://docs.remote.it/software/device-package/installation#3.-claim-and-register-the-device\e[0m\n" From dd3bf7381aad64323dfcdfb9c01d32705c643146 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Apr 2022 22:58:28 -0400 Subject: [PATCH 5/8] Explain roles/remoteit + avoid contention among its 3 services --- roles/remoteit/README.md | 14 +++++++------- roles/remoteit/tasks/enable-or-disable.yml | 22 +++++++++++++--------- roles/remoteit/templates/iiab-remoteit | 14 +++++++------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/roles/remoteit/README.md b/roles/remoteit/README.md index dbaa5251d..bb8e8d622 100644 --- a/roles/remoteit/README.md +++ b/roles/remoteit/README.md @@ -12,20 +12,20 @@ For other approaches, please see http://FAQ.IIAB.IO -> "How can I remotely manag 1. Browse to [https://remote.it](https://remote.it) (Web Portal) and sign up for an account. -2. Download and install the remote.it [desktop application](https://remote.it/download/) (e.g. for Windows, macOS or Linux) on your own laptop/computer. Their https://remote.it Web Portal and [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages) are also sometimes possible, but less functional. +2. Download and install the remote.it [desktop application](https://remote.it/download/) (e.g. for Windows, macOS or Linux) on your own laptop/computer. Their https://remote.it Web Portal and [mobile apps](https://docs.remote.it/introduction/get-started/readme#installation-packages) are also sometimes sufficient, but less functional. COMPARISON: "The Desktop and [CLI](https://docs.remote.it/software/cli) can [each] support both peer to peer connections and proxy connections [whereas] the Web Portal and API can only support proxy connections" according to https://docs.remote.it/software/device-package/usage ### Generate a remote.it claim code for your IIAB + register it + authorize services/ports -Prerequisite: Find an IIAB with `remoteit_installed: True` in `/etc/iiab/iiab_state.yml`. +Prerequisite: Find an IIAB with `remoteit_installed: True` in `/etc/iiab/iiab_state.yml` 1. Run `sudo iiab-remoteit` Hit `[Enter]` twice if you want to quickly generate a new claim code for your IIAB. - The claim code is stored in `/etc/remoteit/config.json` and must be used [within 24 hours](https://docs.remote.it/device-package/installation#2.-update-your-package-manager-and-install). + The claim code is put in `/etc/remoteit/config.json` and must be used [within 24 hours](https://docs.remote.it/device-package/installation#2.-update-your-package-manager-and-install).