Format scripts with shfmt
This commit is contained in:
parent
7aa6142adb
commit
3599220815
2 changed files with 66 additions and 70 deletions
|
@ -1,16 +1,14 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
run_hook ()
|
run_hook() {
|
||||||
{
|
[ -d /dev/pts ] || mkdir -p /dev/pts
|
||||||
[ -d /dev/pts ] || mkdir -p /dev/pts
|
mount -t devpts devpts /dev/pts
|
||||||
mount -t devpts devpts /dev/pts
|
|
||||||
|
|
||||||
echo "Starting dropbear"
|
echo "Starting dropbear"
|
||||||
/usr/sbin/dropbear -E -s -j -k
|
/usr/sbin/dropbear -E -s -j -k
|
||||||
}
|
}
|
||||||
|
|
||||||
run_cleanuphook ()
|
run_cleanuphook() {
|
||||||
{
|
|
||||||
umount /dev/pts
|
umount /dev/pts
|
||||||
rm -R /dev/pts
|
rm -R /dev/pts
|
||||||
if [ -f /var/run/dropbear.pid ]; then
|
if [ -f /var/run/dropbear.pid ]; then
|
||||||
|
|
122
dropbear_install
122
dropbear_install
|
@ -1,97 +1,95 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
get_fingerprint() {
|
get_fingerprint() {
|
||||||
keyfile="$1"
|
keyfile="$1"
|
||||||
dropbearkey -y -f "${keyfile}" | sed -n '/^Fingerprint:/ {s/Fingerprint: *//; p}'
|
dropbearkey -y -f "${keyfile}" | sed -n '/^Fingerprint:/ {s/Fingerprint: *//; p}'
|
||||||
}
|
}
|
||||||
|
|
||||||
display_fingerprints() {
|
display_fingerprints() {
|
||||||
keyfile
|
keyfile
|
||||||
|
|
||||||
for keyfile in "/etc/dropbear/dropbear_rsa_host_key" "/etc/dropbear/dropbear_ecdsa_host_key" ; do
|
for keyfile in "/etc/dropbear/dropbear_rsa_host_key" "/etc/dropbear/dropbear_ecdsa_host_key"; do
|
||||||
if [ -s "${keyfile}" ] ; then
|
if [ -s "${keyfile}" ]; then
|
||||||
echo "$(basename "${keyfile}") : $(get_fingerprint "${keyfile}")"
|
echo "$(basename "${keyfile}") : $(get_fingerprint "${keyfile}")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_openssh_keys() {
|
copy_openssh_keys() {
|
||||||
osshrsa="/etc/ssh/ssh_host_rsa_key"
|
osshrsa="/etc/ssh/ssh_host_rsa_key"
|
||||||
osshecdsa="/etc/ssh/ssh_host_ecdsa_key"
|
osshecdsa="/etc/ssh/ssh_host_ecdsa_key"
|
||||||
|
|
||||||
dbpre="/etc/dropbear/dropbear_"
|
dbpre="/etc/dropbear/dropbear_"
|
||||||
|
|
||||||
return_code=1
|
return_code=1
|
||||||
|
|
||||||
if [ -s "$osshrsa" ]; then
|
if [ -s "$osshrsa" ]; then
|
||||||
dropbearconvert openssh dropbear $osshrsa ${dbpre}rsa_host_key
|
dropbearconvert openssh dropbear $osshrsa ${dbpre}rsa_host_key
|
||||||
return_code=0
|
return_code=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "$osshecdsa" ]; then
|
if [ -s "$osshecdsa" ]; then
|
||||||
dropbearconvert openssh dropbear $osshecdsa ${dbpre}ecdsa_host_key
|
dropbearconvert openssh dropbear $osshecdsa ${dbpre}ecdsa_host_key
|
||||||
return_code=0
|
return_code=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $return_code
|
return $return_code
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_keys() {
|
generate_keys() {
|
||||||
keyfile keytype
|
keyfile keytype
|
||||||
for keytype in rsa ecdsa ; do
|
for keytype in rsa ecdsa; do
|
||||||
keyfile="/etc/dropbear/dropbear_${keytype}_host_key"
|
keyfile="/etc/dropbear/dropbear_${keytype}_host_key"
|
||||||
if [ ! -s "$keyfile" ]; then
|
if [ ! -s "$keyfile" ]; then
|
||||||
echo "Generating ${keytype} host key for dropbear ..."
|
echo "Generating ${keytype} host key for dropbear ..."
|
||||||
dropbearkey -t "${keytype}" -f "${keyfile}"
|
dropbearkey -t "${keytype}" -f "${keyfile}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
build ()
|
build() {
|
||||||
{
|
#
|
||||||
#
|
# Begin real processing
|
||||||
# Begin real processing
|
#
|
||||||
#
|
|
||||||
|
|
||||||
# Are we even needed?
|
# Are we even needed?
|
||||||
if [ ! -r "/etc/dropbear/root_key" ] || [ ! -s "/etc/dropbear/root_key" ]; then
|
if [ ! -r "/etc/dropbear/root_key" ] || [ ! -s "/etc/dropbear/root_key" ]; then
|
||||||
echo "There is no root key in /etc/dropbear/root_key existent; exit"
|
echo "There is no root key in /etc/dropbear/root_key existent; exit"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if TMPDIR is set leave it alone otherwise set
|
# if TMPDIR is set leave it alone otherwise set
|
||||||
[ -z "$TMPDIR" ] && TMPDIR='/tmp/dropbear_initrd_encrypt'
|
[ -z "$TMPDIR" ] && TMPDIR='/tmp/dropbear_initrd_encrypt'
|
||||||
|
|
||||||
# check if TMPDIR exsists if not make it
|
# check if TMPDIR exsists if not make it
|
||||||
[ -d "$TMPDIR" ] || mkdir -p "$TMPDIR"
|
[ -d "$TMPDIR" ] || mkdir -p "$TMPDIR"
|
||||||
|
|
||||||
umask 0022
|
umask 0022
|
||||||
|
|
||||||
[ -d /etc/dropbear ] && mkdir -p /etc/dropbear
|
[ -d /etc/dropbear ] && mkdir -p /etc/dropbear
|
||||||
|
|
||||||
copy_openssh_keys || generate_keys
|
copy_openssh_keys || generate_keys
|
||||||
display_fingerprints
|
display_fingerprints
|
||||||
|
|
||||||
add_checked_modules "/drivers/net/"
|
add_checked_modules "/drivers/net/"
|
||||||
add_binary "rm"
|
add_binary "rm"
|
||||||
add_binary "killall"
|
add_binary "killall"
|
||||||
add_binary "dropbear"
|
add_binary "dropbear"
|
||||||
|
|
||||||
add_dir "/root/.ssh"
|
add_dir "/root/.ssh"
|
||||||
cat /etc/dropbear/root_key > "${BUILDROOT}"/root/.ssh/authorized_keys
|
cat /etc/dropbear/root_key >"${BUILDROOT}"/root/.ssh/authorized_keys
|
||||||
|
|
||||||
add_full_dir "/etc/dropbear"
|
add_full_dir "/etc/dropbear"
|
||||||
add_file "/lib/libnss_files.so.2"
|
add_file "/lib/libnss_files.so.2"
|
||||||
add_dir "/var/run"
|
add_dir "/var/run"
|
||||||
add_dir "/var/log"
|
add_dir "/var/log"
|
||||||
touch "${BUILDROOT}"/var/log/lastlog
|
touch "${BUILDROOT}"/var/log/lastlog
|
||||||
|
|
||||||
add_runscript
|
add_runscript
|
||||||
}
|
}
|
||||||
|
|
||||||
help ()
|
help() {
|
||||||
{
|
cat <<HELPEOF
|
||||||
cat<<HELPEOF
|
|
||||||
This hook is meant to be used in conjunction with mkinitcpio-netconf and/or
|
This hook is meant to be used in conjunction with mkinitcpio-netconf and/or
|
||||||
mkinitcpio-ppp. It DOES NOT provide any default shell. It will only install
|
mkinitcpio-ppp. It DOES NOT provide any default shell. It will only install
|
||||||
and start dropbear on early userspace. In the package mkinitcpio-utils you
|
and start dropbear on early userspace. In the package mkinitcpio-utils you
|
||||||
|
|
Loading…
Reference in a new issue