49,37 → 49,8 |
;; |
esac |
|
create_seed_and_key() { |
if [ ! -f "$RANDOM_SEED" ]; then |
log_action_begin_msg "Creating lsh random seed file (this only needs to be done once)" |
DIR=$(dirname "$RANDOM_SEED") |
if install -d -m 700 "$DIR" && |
dd if=/dev/random "of=$RANDOM_SEED" bs=1 count=32 2>/dev/null && |
chmod 600 "$RANDOM_SEED"; then |
log_action_end_msg 0 |
else |
log_action_end_msg 1 |
exit 1 |
fi |
fi |
|
if [ ! -f "$HOST_KEY" ]; then |
log_action_begin_msg "Creating lsh host key (this only needs to be done once)" |
lsh-keygen --server | lsh-writekey --server --output-file "$HOST_KEY" |
|
if [ ! -f "$HOST_KEY" ]; then |
log_action_end_msg 1 |
exit 1 |
fi |
|
log_action_end_msg 0 |
fi |
} |
|
|
case "$1" in |
start) |
create_seed_and_key |
log_daemon_msg "Starting $DESC" "$NAME" |
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON \ |
-- --daemonic --port "$LSHD_PORT" $SFTP_FLAG |
94,7 → 65,6 |
log_end_msg $? |
;; |
restart|force-reload) |
create_seed_and_key |
log_daemon_msg "Restarting $DESC" "$NAME" |
start-stop-daemon --stop --retry HUP/1 --quiet --pidfile $PIDFILE \ |
--oknodo --exec $DAEMON && |