diff --git a/README.md b/README.md index 04276a1ff..29a75a98f 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ help [command] gives you a more detailed info about t verbose makes each command print more output (might not work with treehouses remote) expandfs expands the partition of the RPI image to the maximum of the SD card rename changes hostname -password changes the password for 'pi' user or disables/enables password authentication +password changes the password for 'pi' user or disables/enables password authentication sshkey used for adding or removing ssh keys for authentication version [contributors|remote] returns the version of treehouses CLI, remote, or list of contributors image returns version of the system image installed diff --git a/_treehouses b/_treehouses index d406bb2c9..c56582185 100644 --- a/_treehouses +++ b/_treehouses @@ -263,7 +263,7 @@ treehouses openvpn show treehouses openvpn start treehouses openvpn stop treehouses openvpn use -treehouses password +treehouses password change treehouses password disable treehouses password enable treehouses picture diff --git a/modules/help.sh b/modules/help.sh index e4766da04..f1efa1592 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -10,7 +10,7 @@ help [command] gives you a more detailed info about t verbose makes each command print more output (might not work with treehouses remote) expandfs expands the partition of the RPI image to the maximum of the SD card rename changes hostname -password changes the password for 'pi' user or disables/enables password authentication +password changes the password for 'pi' user or disables/enables password authentication sshkey used for adding or removing ssh keys for authentication version [contributors|remote] returns the version of treehouses CLI, remote, or list of contributors image returns version of the system image installed diff --git a/modules/password.sh b/modules/password.sh index 935d29013..1c9b423ea 100644 --- a/modules/password.sh +++ b/modules/password.sh @@ -1,21 +1,31 @@ function password { checkrpi checkroot - checkargn $# 1 + checkargn $# 2 options="$1" + case "$options" in - "") - log_and_exit1 "Error: Password not entered" + "change") + case "$2" in + "") + log_and_exit1 "Error: Password not entered" + ;; + *) + chpasswd <<< "pi:$2" + echo "Success: the password has been changed" + ;; + esac ;; "disable") + checkargn $# 1 disablepassword ;; "enable") + checkargn $# 1 enablepassword ;; *) - chpasswd <<< "pi:$options" - echo "Success: the password has been changed" + log_help_and_exit1 "Error: Must use an option to 'change', 'disable', or 'enable'" "password" ;; esac } @@ -34,13 +44,13 @@ function enablepassword { function password_help () { echo - echo "Usage: $BASENAME password " + echo "Usage: $BASENAME password change " echo " $BASENAME password [disable|enable]" echo echo "Changes the password for 'pi' user" echo echo "Example:" - echo " $BASENAME password ABC" + echo " $BASENAME change password ABC" echo " Sets the password for 'pi' user to 'ABC'." echo echo " $BASENAME password disable" diff --git a/package.json b/package.json index fa10827c6..9f987ba4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.25.19", + "version": "1.25.20", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh", diff --git a/tests/password.bats b/tests/password.bats index 504db8e8d..496a67ef6 100755 --- a/tests/password.bats +++ b/tests/password.bats @@ -2,6 +2,6 @@ load test-helper @test "$clinom password raspberry" { - run "${clicmd}" password raspberry + run "${clicmd}" password change raspberry assert_success -} \ No newline at end of file +}