This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate ssh key script from cloudinit script
- Loading branch information
Showing
6 changed files
with
91 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
vyos-cloudinit (0.3.0) unstable; urgency=low | ||
|
||
* Separate ssh key script from cloudinit script | ||
|
||
-- Yuya Kusakabe <[email protected]> Fri, 30 Dec 2016 13:11:05 +0900 | ||
|
||
vyos-cloudinit (0.2.1) unstable; urgency=low | ||
|
||
* Remove command option from scripts/vyos-cloudinit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: vyos-ssh-key | ||
# Required-Start: vyos-cloudinit | ||
# Required-Stop: | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: | ||
# Short-Description: Load user SSH key. | ||
# Description: Load user SSH key. | ||
### END INIT INFO | ||
|
||
. /lib/lsb/init-functions | ||
|
||
: ${vyatta_env:=/etc/default/vyatta} | ||
source $vyatta_env | ||
|
||
log_action_begin_msg "Starting vyos-ssh-key" | ||
${vyatta_sbindir}/vyos-ssh-key | ||
log_action_end_msg $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/vbash | ||
|
||
: ${vyatta_env:=/etc/default/vyatta} | ||
source $vyatta_env | ||
|
||
ENVIRONMENT="" | ||
SSH_KEY="" | ||
SSH_USER="vyos" | ||
|
||
CONF_DIR="${vyatta_sysconfdir}/vyos-cloudinit" | ||
. ${CONF_DIR}/vyos-cloudinit.conf | ||
|
||
if [ -n "${ENVIRONMENT}" ]; then | ||
env_conf=${CONF_DIR}/${ENVIRONMENT}.conf | ||
if [ -f ${env_conf} ]; then | ||
. ${env_conf} | ||
else | ||
echo "${ENVIRONMENT} is not supported" | ||
fi | ||
fi | ||
|
||
# override with user specified parameters | ||
. ${CONF_DIR}/vyos-cloudinit.conf | ||
|
||
if [[ -z "${SSH_KEY}" ]]; then | ||
echo "ssh-key not specified" | ||
exit 0 | ||
fi | ||
|
||
LOAD_KEY="${vyatta_sbindir}/vyatta-load-user-key.pl" | ||
|
||
_exit=exit | ||
source ${vyatta_sysconfdir}/functions/script-template | ||
|
||
function load_key() { | ||
echo "loading ssh key..." | ||
${LOAD_KEY} ${SSH_USER} ${SSH_KEY} | ||
} | ||
|
||
if [[ -n "${SSH_KEY}" && "${SSH_KEY}" == "http"* ]]; then | ||
/usr/bin/curl -m 3 -sf "${SSH_KEY}" | ||
if [ $? -ne 0 ]; then | ||
echo "could not retrieve ssh key from ${SSH_KEY}" | ||
$_exit 1 | ||
else | ||
load_key | ||
$_exit $? | ||
fi | ||
elif [[ -n "${SSH_KEY}" ]]; then | ||
load_key | ||
$_exit $? | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
priority: 400 | ||
help: Cloud init | ||
create: sudo /usr/sbin/update-rc.d vyos-cloudinit defaults | ||
sudo /usr/sbin/update-rc.d vyos-ssh-key defaults | ||
|
||
delete: sudo /usr/sbin/update-rc.d -f vyos-cloudinit remove | ||
sudo /usr/sbin/update-rc.d -f vyos-ssh-key remove |