Convert scripts to posix sh

This commit is contained in:
Marko Korhonen 2024-05-09 11:02:17 +03:00
parent 688ee538ae
commit 7aa6142adb
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890
2 changed files with 13 additions and 13 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/ash #!/bin/sh
run_hook () run_hook ()
{ {
@ -14,6 +14,6 @@ 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
kill `cat /var/run/dropbear.pid` kill "$(cat /var/run/dropbear.pid)"
fi fi
} }

View file

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/sh
get_fingerprint() { get_fingerprint() {
local 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() {
local 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
@ -16,12 +16,12 @@ display_fingerprints() {
} }
copy_openssh_keys() { copy_openssh_keys() {
local osshrsa="/etc/ssh/ssh_host_rsa_key" osshrsa="/etc/ssh/ssh_host_rsa_key"
local osshecdsa="/etc/ssh/ssh_host_ecdsa_key" osshecdsa="/etc/ssh/ssh_host_ecdsa_key"
local dbpre="/etc/dropbear/dropbear_" dbpre="/etc/dropbear/dropbear_"
local 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
@ -37,7 +37,7 @@ copy_openssh_keys() {
} }
generate_keys() { generate_keys() {
local 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
@ -54,16 +54,16 @@ build ()
# #
# Are we even needed? # Are we even needed?
if [ ! -r "/etc/dropbear/root_key" -o ! -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