[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] Automatic login
Hi again Raul,
Torrego Raul wrote:
I'm trying to connect my board via telnet, but I've realized that this
is not possible until the login/password is typed (my intention was to
do this via telnet) so, is there any way of getting an automatic login?
This is, is there something that can be configured so that petalinux
starts itself?
This is such a useful functionality I had to go and do it streaght away!
The attached patch should apply cleanly to a petalinux-v0.30 tree.
No custom vendor Makefile hacking required, it just adds some new
menuconfig options under
Customise user/vendor settings -> System settings:
[*] Autologin
Autologin application: "/bin/sh"
If autologin is enabled, it defaults to running "/bin/sh" which will
boot direct to a shell prompt.
However, you may wish it to run your own app on startup instead, just
edit the "Autologin application" field and point it to the binary you
require. Parameters can be specified sperated by spaces as expected.
Obviously if you get this wrong you'll have a very unhappy system on bootup.
This feature will be in the next release.
Regards,
John
Index: vendors/PetaLogix/common/common.mak
===================================================================
--- vendors/PetaLogix/common/common.mak (revision 3990)
+++ vendors/PetaLogix/common/common.mak (revision 3992)
@@ -235,8 +235,14 @@
$(ROMFSINST) -A "^root:" -a "root:${CRYPT_PASSWD}:0:0::/:/bin/sh" $(ETCDIR)/passwd
ifdef CONFIG_USER_INIT_INIT
+ # Strip any existing ttyS0 inittab handling
+ $(ROMFSINST) -r "^ttyS0:.*" /etc/inittab
+ifdef CONFIG_SYSTEM_AUTOLOGIN
+ $(ROMFSINST) -a "ttyS0:vt100:$(CONFIG_SYSTEM_AUTOLOGIN_APP)" /etc/inittab
+else
$(ROMFSINST) -e CONFIG_USER_AGETTY_AGETTY \
-a "ttyS0:vt100:/bin/agetty ttyS0 115200" /etc/inittab
+endif
$(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD \
-a "flt:unknown:/bin/flatfsd" /etc/inittab
$(ROMFSINST) -e CONFIG_USER_INETD_INETD \
@@ -251,12 +257,16 @@
ifdef CONFIG_USER_BUSYBOX_INIT
$(ROMFSINST) $(COMMON)/etc/rc/sysinit /etc/rc.sysinit
$(ROMFSINST) $(COMMON)/etc/rc/reboot /etc/rc.reboot
+ifdef CONFIG_SYSTEM_AUTOLOGIN
+ $(ROMFSINST) $(COMMON)/etc/inittab.sh /etc/inittab
+else
ifdef CONFIG_USER_AGETTY_AGETTY
$(ROMFSINST) $(COMMON)/etc/inittab.agetty /etc/inittab
else
$(ROMFSINST) $(COMMON)/etc/inittab.sh /etc/inittab
endif
endif
+endif
$(ROMFSINST) -e CONFIG_USER_BUSYBOX_HOSTNAME \
$(COMMON)/etc/rc/hostname /etc/init.d/hostname
$(ROMFSINST) -e CONFIG_USER_SYSUTILS_HOSTNAME \
Index: config/Configure.help
===================================================================
--- config/Configure.help (revision 3990)
+++ config/Configure.help (revision 3992)
@@ -4072,6 +4072,13 @@
CONFIG_SYSTEM_HOSTNAME
The host name of your system.
+CONFIG_SYSTEM_AUTOLOGIN
+ Automatically login to a root shell, do not prompt for username/password
+
+CONFIG_SYSTEM_AUTOLOGIN_APP
+ Application to run on autologin - default is /bin/sh, the shell. Change this to your own application to run
+ automatically on startup.
+
CONFIG_SYSTEM_ROOT_PASSWD
The default root password for your system.
Index: config/config.in
===================================================================
--- config/config.in (revision 3990)
+++ config/config.in (revision 3992)
@@ -20,7 +20,7 @@
mainmenu_option next_comment
comment 'Network Addresses'
string 'Ethernet MAC address' CONFIG_SYSTEM_MAC_ADDRESS '00:0a:35:00:22:01'
-bool 'Obtain IP address automatically' CONFIG_SYSTEM_USE_DHCP
+bool 'Obtain IP address automatically' CONFIG_SYSTEM_USE_DHCP 'n'
if [ "$CONFIG_SYSTEM_USE_DHCP" = "n" ]; then
string 'Static IP address' CONFIG_SYSTEM_IP_ADDRESS '192.168.0.54'
string 'Server IP address' CONFIG_SYSTEM_SERVERIP_ADDRESS '192.168.0.15'
@@ -28,6 +28,12 @@
endmenu # End of Target Network Addresses submenu
string 'Default host name' CONFIG_SYSTEM_HOSTNAME ${CONFIG_PRODUCT}
+
+bool 'Autologin' CONFIG_SYSTEM_AUTOLOGIN 'n'
+if [ "$CONFIG_SYSTEM_AUTOLOGIN" = "y" ]; then
+ string 'Autologin application' CONFIG_SYSTEM_AUTOLOGIN_APP '/bin/sh'
+fi
+
string 'Default root password' CONFIG_SYSTEM_ROOT_PASSWD 'root'
choice 'Root filesystem type' "CRAMFS CONFIG_SYSTEM_ROOTFS_CRAMFS \
ROMFS CONFIG_SYSTEM_ROOTFS_ROMFS \
Index: tools/romfs-inst.sh
===================================================================
--- tools/romfs-inst.sh (revision 3990)
+++ tools/romfs-inst.sh (revision 3992)
@@ -22,6 +22,7 @@
-S : don't strip after installing
-a text : append text to dst.
-A pattern : only append text if pattern doesn't exist in file
+ -r pattern : remove lines from dst matching pattern
-l link : dst is a hard link to 'link'.
-s sym-link : dst is a sym-link to 'sym-link'.
@@ -108,6 +109,21 @@
return $?
}
+file_remove()
+{
+ touch ${ROMFSDIR}${dst} || return 1
+ if [ -z "${pattern}" ]
+ then
+ [ "$v" ] && echo "No pattern specified for removal, doing nothing"
+ else
+ [ "$v" ] && echo "Removing pattern"
+ egrep -v ${pattern} < ${ROMFSDIR}${dst} >> /tmp/$$
+ mv /tmp/$$ ${ROMFSDIR}${dst}
+ fi
+ setperm ${ROMFSDIR}${dst}
+ return $?
+}
+
#############################################################################
hard_link()
@@ -150,7 +166,7 @@
dst=
strip=1
-while getopts 'dSve:o:A:p:a:l:s:' opt "$@"
+while getopts 'dSve:o:A:r:p:a:l:s:' opt "$@"
do
case "$opt" in
v) v="1"; ;;
@@ -161,6 +177,7 @@
p) perm="$OPTARG"; ;;
a) src="$OPTARG"; func=file_append; ;;
A) pattern="$OPTARG"; ;;
+ r) pattern="$OPTARG"; func=file_remove; ;;
l) src="$OPTARG"; func=hard_link; ;;
s) src="$OPTARG"; func=sym_link; ;;