base-files: firstboot: only ask for confirmation on TTY
authorJonas Gorski <jogo@openwrt.org>
Wed, 27 Mar 2013 12:39:42 +0000 (12:39 +0000)
committerJonas Gorski <jogo@openwrt.org>
Wed, 27 Mar 2013 12:39:42 +0000 (12:39 +0000)
Also allow '-y' to force the reset.

SVN-Revision: 36133

package/base-files/files/sbin/firstboot

index e7c0851ad045f488751dba3d8a8c42dcf4ddd4cf..06b64c31332e48bb1025a7fd3dad9a3c139e6376 100755 (executable)
@@ -21,11 +21,13 @@ if [ "${0##*/}" = "firstboot" ]; then
     if [ "$1" = "switch2jffs" ]; then
        boot_run_hook switch2jffs
     else
-       local input
+       if [ -t 0 ] && [ "$1" != "-y" ]; then
+               local input
 
-       echo -n  "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
-       read input
-       [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
+               echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
+               read input
+               [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
+       fi
 
        if [ -n "$jffs" ]; then
            reset_has_fo=true