12 Usage: adduser-novaboot --key KEY [--admin-id=NAME] [adduser options] user
16 TEMP=$(getopt -o 'h' --long 'admin-id:,key:,help,home:,uid:,firstuid:,lastuid:,gecos:,ingroup:,gid:' -n "${0##*/}" -- "$@")
17 [ $? -ne 0 ] && die "getopt error"
36 adduser_opts="$adduser_opts $1 $2"
41 [ -z "$keysrc" ] && die "Missing --key option"
43 if [ "$keysrc" = "-" ]; then
49 [ -z "$key" -o "$(echo "$key" | wc -l)" -ne 1 ] && die "--key needs to be just one line"
50 echo "$key" | grep -q ssh || die "--key does not look like an SSH public key"
52 adduser --disabled-password --ingroup novaboot --shell $(which novaboot-shell) $adduser_opts "$@"
55 home=$(getent passwd "$user"|awk -F: '{print $6;}')
58 echo "Creating $home/.ssh/authorized_keys"
59 mkdir -p -m 700 "$home/.ssh"
60 echo "command=\"user $admin admin\" $key" >> $home/.ssh/authorized_keys
61 chown $user: "$home/.ssh" "$home/.ssh/authorized_keys"
63 if [ -d /srv/tftp -a ! -e /srv/tftp/$user ]; then
64 echo "Creating /srv/tftp/$user and symlink to it from $home/tftproot."
65 mkdir -p /srv/tftp/$user
66 chown $user /srv/tftp/$user
67 ln -s /srv/tftp/$user $home/tftproot
69 echo "NOT creating /srv/tftp/$user and symlink to it from $home/tftproot."
72 echo "Creating configuration template in $home/.novaboot-shell"
73 cat <<'CONFIG_EOF' > $home/.novaboot-shell
76 # Configuration for novaboot-shell
79 #console_cmd='sterm -s 115200 /dev/ttyUSB0'
81 #reset_cmd='/bin/sh -c "(usbrelay LY03X_2=1; sleep 0.1; usbrelay LY03X_2=0) 2>/dev/null"'
83 #on_cmd='/bin/sh -c "(usbrelay LY03X_1=1; sleep 0.1; usbrelay LY03X_1=0) 2>/dev/null"';
84 #off_cmd='/bin/sh -c "(usbrelay LY03X_1=1; sleep 7.0; usbrelay LY03X_1=0) 2>/dev/null"';
89 # --uboot-init=setenv serverip 192.168.1.1
90 # --uboot-addr=kernel=0x81000000
91 # --uboot-addr=fdt=0x83000000
92 # --uboot-addr=ramdisk=0x83100000
95 chown $user: $home/.novaboot-shell
97 if [ -d /run/systemd/system ]; then
99 See adduser-novaboot(8) for instructions how to automatically power of
114 adduser-novaboot - create user account for use with novaboot's --ssh option
118 B<adduser-novaboot> --key KEY [--admin-id NAME] [adduser options] user
122 B<adduser-novaboot> is a wrapper of L<adduser(8)> command that
123 simplifies creation of user accounts for I<novaboot>'s --ssh option.
124 The created account has its shell set to L<novaboot-shell(1)>. The
125 command also creates a template of the configuration file, sets up
126 administrator's SSH key in L<authorized_keys(5)> prepares directories
127 and symlinks that for integration with TFTP server.
129 =head2 Automatic power-off
131 When your system uses L<systemd(1)>, you can configure a systemd
132 service to automatically power-off the target after timeout. To enable
135 systemctl --user enable novaboot-delayed-power-off
137 as the created user (e.g. via shell subcommand). To enable delayed
138 power-off for all novaboot-shell account, run the follwing as root:
140 systemctl --global enable novaboot-delayed-power-off
142 Individual accounts may disable this global configuration by running:
144 systemctl --user mask novaboot-delayed-power-off
146 The power-off timeout is hardcoded in the B<novaboot-power-off@.timer>
147 unit. To override the timeout, run C<systemctl edit
148 novaboot-power-off@TARGET.timer> for your B<TARGET> and insert the
149 following to the spawned editor:
160 Mandatory argument specifying administrator's public SSH key (e.g.
161 F<~/.ssh/id_rsa.pub>). The key will be copied to the created account's
162 F<~/.ssh/authorized_keys> and marked with administrator flag.
164 =item --admin-id NAME
166 User name associated with the key. This user name is shown to
167 connecting users when the target is occupied by the administrator.
168 When omitted, I<admin> is used as the user name.
174 Michal Sojka <sojkam1@fel.cvut.cz>
176 Latest version can be found at
177 L<https://github.com/wentasah/novaboot>.