Skip to content

Commit

Permalink
fix: script for ssh host key setup
Browse files Browse the repository at this point in the history
The script only should run once and disable itself. It should also be not
enabled by default and should be started by an extra mdata / zoneinit script.
  • Loading branch information
drscream committed Jun 2, 2015
1 parent 4059897 commit 7839931
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
5 changes: 1 addition & 4 deletions copy/opt/core/lib/svc/manifest/ssh-hostkey-mdata-setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="ssh-hostkey-mdata-setup">
<service name="network/ssh-hostkey-mdata-setup" type="service" version="1">
<create_default_instance enabled="true"/>
<create_default_instance enabled="false"/>
<single_instance/>
<dependency name="network" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/milestone/network:default"/>
Expand All @@ -15,9 +15,6 @@
</dependency>
<exec_method type="method" name="start" exec="/opt/core/lib/svc/method/ssh-hostkey-mdata-setup" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec="true" timeout_seconds="60"/>
<property_group name='application' type='application'>
<propval name='done' type='boolean' value='false'/>
</property_group>
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="transient"/>
<propval name="ignore_error" type="astring" value="core,signal"/>
Expand Down
9 changes: 3 additions & 6 deletions copy/opt/core/lib/svc/method/ssh-hostkey-mdata-setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
# Set basedir and default config file
SSH_HOSTS='/var/ssh'

# Do nothing if not under SMF, not provisioning, or already done.
if [[ ! "${SMF_METHOD}" == "start" ]] || \
[[ $(svcprop -p application/done ssh-hostkey-mdata-setup) =~ true ]]; then
# Do nothing if not under SMF
if [[ ! "${SMF_METHOD}" == "start" ]]; then
exit ${SMF_EXIT_OK}
fi

Expand All @@ -24,9 +23,7 @@ for key in dsa_key dsa_key.pub rsa_key rsa_key.pub; do
fi
done

# Setup service to run only once
svccfg -s svc:/network/ssh-hostkey-mdata-setup 'setprop application/done = true'
svcadm refresh svc:/network/ssh-hostkey-mdata-setup
# Disable service after run once
svcadm disable svc:/network/ssh-hostkey-mdata-setup

exit ${SMF_EXIT_OK}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svcadm enable svc:/network/ssh-hostkey-mdata-setup:default

0 comments on commit 7839931

Please sign in to comment.