# Custom nanobsd functions



## adam2104 (Mar 18, 2012)

I've been playing with nanobsd for the last couple weeks. I thought it would be useful to share some of the custom functions I came up with.

First up, this one adjusts the serial console, ttyu0, to use the vt100 terminal type. This ensures that things like vi work properly on the serial console:

```
cust_settermtype () (
	# set vt100 term type on console
	sed -i "" -e /tty[du]0/s/dialup/vt100/ ${NANO_WORLDDIR}/etc/ttys
)
customize_cmd cust_comconsole
```

Second up, this one adjusts /etc/syslog.conf so that console output is directed to /var/log/console.log:


```
cust_syslog() (
	sed -i "" -e /#console.info/s/#// ${NANO_WORLDDIR}/etc/syslog.conf
	touch ${NANO_WORLDDIR}/var/log/console.log
	chmod 644 ${NANO_WORLDDIR}/var/log/console.log
)
customize_cmd cust_syslog
```

Hope this helps some people out. Feel free to share any functions you may have.


----------



## egeltje (Apr 9, 2012)

Great idea! Here are some of mine.

I manage a lot of build scripts for different machines. Some machines require more files to be pre-installed, so I keep them with the build script like the custom packages.


```
NANO_FILES_DIR=/path/to/buildscript/Files

cust_my_files() (
	cd ${NANO_FILES_DIR}
	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${NANO_WORLDDIR}
)
customize_cmd cust_my_files
```

I like to install some default users in advance.

```
NANO_USERS="user1 user2"
NANO_ADMIN_USERS="user3"

cust_users() (
	for NANO_ADMIN_USER in ${_NANO_ADMIN_USERS}; do
		echo "Creating admin user $NANO_ADMIN_USER"
		echo "password" | pw -V ${NANO_WORLDDIR}/etc useradd $NANO_ADMIN_USER -d /etc/home/$NANO_ADMIN_USER -m -s /bin/csh -h 0
	done

	for NANO_USER in ${NANO_USERS}; do
		echo "Creating admin user $NANO_USER"
		echo "password" | pw -V ${NANO_WORLDDIR}/etc useradd $NANO_USER -d /etc/home/$NANO_USER -m -s /bin/csh -h 0
	done
)
customize_cmd cust_users
```

NOTE: The password on all accounts is set to "password". In my custom scripts I tune this of course.
Also, *I* add a .hushlogin to the user's home directory, so the motd is not displayed when logging in. rsync is very picky about this.


----------



## egeltje (Apr 9, 2012)

Hmmm, I can't make changes to a post. The second 
	
	



```
echo "Creating admin user $NANO_USER"
```
 in the cust_users function should of course be 
	
	



```
echo "Creating user $NANO_USER"
```


----------

