diff --git a/scripts/change-hostname-as-root.sh b/scripts/change-hostname-as-root.sh deleted file mode 100755 index e66bc339..00000000 --- a/scripts/change-hostname-as-root.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -if [ "$EUID" -ne 0 ] - then - echo "ERROR: Please run as root" - exit -fi - -if [ "$#" -ne 1 ] - then - echo "Missing hostname parameter" - exit -fi - -CURRENT_HOSTNAME=$(tr -d " \t\n\r" < /etc/hostname) -echo "$1" > /etc/hostname -if sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$1/g" /etc/hosts -then - echo "Hostname has been changed, please reboot your Raspberry Pi for the change to take effect" -else - echo "An error occured while attempting to change the hostname" - exit 1 -fi diff --git a/scripts/change-hostname.sh b/scripts/change-hostname.sh deleted file mode 100755 index cd7c340d..00000000 --- a/scripts/change-hostname.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -sudo "$SCRIPT_DIR"/change-hostname-as-root.sh "$1" diff --git a/scripts/ratos-common.sh b/scripts/ratos-common.sh index 353ae57d..8430d03e 100755 --- a/scripts/ratos-common.sh +++ b/scripts/ratos-common.sh @@ -252,18 +252,5 @@ pi ALL=(ALL) NOPASSWD: /home/pi/printer_data/config/RatOS/scripts/moonraker-upd $sudo chown root:root /tmp/030-ratos-githooks $sudo chmod 440 /tmp/030-ratos-githooks $sudo cp --preserve=mode /tmp/030-ratos-githooks /etc/sudoers.d/030-ratos-githooks - - # Whitelist change hostname script - if [[ ! -e /etc/sudoers.d/031-ratos-change-hostname ]] - then - touch /tmp/031-ratos-change-hostname - cat << '#EOF' > /tmp/031-ratos-change-hostname -pi ALL=(ALL) NOPASSWD: /home/pi/printer_data/config/RatOS/scripts/change-hostname-as-root.sh -#EOF - - $sudo chown root:root /tmp/031-ratos-change-hostname - $sudo chmod 440 /tmp/031-ratos-change-hostname - $sudo cp --preserve=mode /tmp/031-ratos-change-hostname /etc/sudoers.d/031-ratos-change-hostname - fi } diff --git a/shell-macros.cfg b/shell-macros.cfg index 21864b08..e8195f4a 100644 --- a/shell-macros.cfg +++ b/shell-macros.cfg @@ -109,17 +109,3 @@ gcode: command: /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh timeout: 90. verbose: True - -[gcode_macro CHANGE_HOSTNAME] -description: Change the hostname of your Raspberry Pi. -gcode: - {% if params.HOSTNAME is not defined %} - RATOS_ECHO MSG='You have to specify a new hostname with the HOSTNAME parameter. Ex: CHANGE_HOSTNAME HOSTNAME="MY_NEW_HOSTNAME"' - RATOS_ECHO MSG="Please note: RFCs mandate that a hostname's labels may contain only the ASCII letters 'a' through 'z' (case-insensitive), the digits '0' through '9', and the hyphen. Hostname labels cannot begin or end with a hyphen. No other symbols, punctuation characters, or blank spaces are permitted." - {% else %} - RUN_SHELL_COMMAND CMD=change_hostname PARAMS={params.HOSTNAME} - {% endif %} - -[gcode_shell_command change_hostname] -command: /home/pi/printer_data/config/RatOS/scripts/change-hostname.sh -timeout: 10.