summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2020-12-30 10:40:14 -0600
committerDaniil Baturin <daniil@vyos.io>2021-01-04 18:10:36 +0200
commit46f7aca3e98472c15f37c74d4097fd5e97542cda (patch)
tree3103c3b47a7cc8e4a8242d3fbcdf3afeebdefc92
parent495bc2cffc1bf4d6b59796b8a1cefe6838352418 (diff)
downloadvyatta-cfg-system-46f7aca3e98472c15f37c74d4097fd5e97542cda.tar.gz
vyatta-cfg-system-46f7aca3e98472c15f37c74d4097fd5e97542cda.zip
migration: T3161: remove scripts ec2-vyos-init, ec2-check.pl
These scripts have been superseded by the cloud-init tools, and contain legacy references to XorpConfigParser.pm (via vyatta-cfg/scripts/vyatta-load-config.pl, via ConfigLoad.pm), which one would like to retire.
-rw-r--r--Makefile.am2
-rwxr-xr-xdebian/vyatta-cfg-system.postinst.in3
-rw-r--r--etc/init.d/ec2-vyos-init146
-rwxr-xr-xscripts/ec2-check.pl40
-rwxr-xr-xscripts/install/install-image-existing31
5 files changed, 0 insertions, 222 deletions
diff --git a/Makefile.am b/Makefile.am
index 7fbb89b2..1e377aef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,6 @@ checkparamsonreboot_SCRIPTS =
checkparamsonreboot_DATA =
checkparamsonreboot_DATA += scripts/check-params-on-reboot.d/README
-initd_SCRIPTS += etc/init.d/ec2-vyos-init
initd_SCRIPTS += etc/init.d/vyatta-config-reboot-params
checkparamsonreboot_SCRIPTS += scripts/check-params-on-reboot.d/ipv6_disable_blacklist
@@ -56,7 +55,6 @@ sbin_SCRIPTS += scripts/install/install-image
sbin_SCRIPTS += scripts/vyatta-bridgegroup-depedency.pl
sbin_SCRIPTS += scripts/vyatta-dhcpv6-client.pl
sbin_SCRIPTS += scripts/vyatta-update-grub.pl
-sbin_SCRIPTS += scripts/ec2-check.pl
sbin_SCRIPTS += scripts/is_port_available.pl
sbin_SCRIPTS += scripts/vyos-persistpath
diff --git a/debian/vyatta-cfg-system.postinst.in b/debian/vyatta-cfg-system.postinst.in
index 53d60f40..be73a3ba 100755
--- a/debian/vyatta-cfg-system.postinst.in
+++ b/debian/vyatta-cfg-system.postinst.in
@@ -177,9 +177,6 @@ update-rc.d vyatta-config-reboot-params start 20 S
# set vyos-intfwatchd to start at boot
update-rc.d vyos-intfwatchd start 2345
-# set ec2-vyos-init to start on boot
-update-rc.d ec2-vyos-init start 2345
-
# Add radius operator user for radius users to map to
if ! grep -q '^radius_user' /etc/passwd; then
adduser --quiet --firstuid 1001 --disabled-login --ingroup users --gecos "radius user" --shell /bin/vbash radius_user
diff --git a/etc/init.d/ec2-vyos-init b/etc/init.d/ec2-vyos-init
deleted file mode 100644
index 78d7be90..00000000
--- a/etc/init.d/ec2-vyos-init
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/bash
-### BEGIN INIT INFO
-# Provides: ec2-vyos-init
-# Required-Start: vyos-router
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop:
-# Short-Description: AWS EC2 instance init script to fetch and load ssh public key
-# Description: Retrieve user's public ssh key from EC2 instance metadata
-# and load/set the key in config.boot
-### END INIT INFO
-
-# Author: hydrajump <wave@hydrajump.com>
-#
-# Based on http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/building-shared-amis.html#public-amis-install-credentials
-# https://github.com/andsens/bootstrap-vz/blob/master/providers/ec2/assets/init.d/ec2-get-credentials
-
-. /lib/lsb/init-functions
-
-# Are we running on AWS?
-/opt/vyatta/sbin/ec2-check.pl
-if [ $? != 0 ]; then
- exit 0
-fi
-
-# Hack for config permissions stuff
-if [ $(groups | awk '{print $1}') != 'vyattacfg' ]; then
- sg vyattacfg $0
- exit
-fi
-
-: ${vyatta_env:=/etc/default/vyatta}
-source $vyatta_env
-
-# Configuration commands
-SHELL_API=/bin/cli-shell-api
-COMMIT=/opt/vyatta/sbin/my_commit
-SAVE=/opt/vyatta/sbin/vyatta-save-config.pl
-LOADKEY=/opt/vyatta/sbin/vyatta-load-user-key.pl
-LOADCONFIG=/opt/vyatta/sbin/vyatta-load-config.pl
-
-userdata_url=http://169.254.169.254/latest/user-data
-public_key_url=http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
-username='vyos'
-ssh_dir="/home/$username/.ssh"
-authorized_keys="$ssh_dir/authorized_keys"
-group='vyattacfg'
-
-# Obtain config session environment
-session_env=$($SHELL_API getSessionEnv $PPID)
-if [ $? -ne 0 ]; then
- echo "An error occured while obtaining session environment!"
- exit 0
-fi
-
-# Evaluate config environment string
-eval $session_env
-
-# Setup the config session
-$SHELL_API setupSession
-if [ $? -ne 0 ]; then
- echo "An error occured while setting up the configuration session!"
- exit 0
-fi
-
-load_user_data ()
-{
- $LOADCONFIG $userdata_url
- $COMMIT
- $SAVE
-}
-
-load_ssh_public_key ()
-{
- # Doesn't work.
- # if [ -x $vyatta_sbindir/vyatta-load-user-key.pl ]; then
- # log_action_msg "Loaded ssh public key for user $username"
- # sg ${group} -c "$vyatta_sbindir/vyatta-load-user-key.pl $username $public_key"
- # fi
-
- # Do this instead
- # Obtain session environment
- # Evaluate environment string
- # Setup the session
- # Commit and save config change
- # Tear down the session
-
- log_action_msg "EC2: Loaded ssh public key for user $username"
- $LOADKEY $username $public_key_url
-
- # Commit and save to config.boot
- $COMMIT
- $SAVE
-}
-
-# Try to load config from instance user-data
-log_action_msg "EC2: -----BEGIN FETCH CONFIG-----"
-log_action_msg "EC2: Requesting config from EC2 instance user-data"
-if (curl --silent -f $userdata_url | grep 'vyatta-config-version' >/dev/null); then
- log_action_msg "EC2: Found Vyos config in EC2 instance user-data"
- load_user_data
-else
- log_action_msg "EC2: No Vyos config found in EC2 instance user-data"
-fi
-
-log_action_msg "EC2: -----END FETCH CONFIG-----"
-# Try to get the ssh public key from instance metadata
-log_action_msg "EC2: -----BEGIN FETCH SSH PUBLIC KEY-----"
-log_action_msg "EC2: Requesting ssh public key from EC2 instance metadata"
-public_key=`/usr/bin/curl --silent -f $public_key_url`
-if [ -n "$public_key" ]; then
- log_action_msg "EC2: Downloaded ssh public key from EC2 instance metadata"
- if [ ! -d $ssh_dir ]; then
- mkdir -m 700 $ssh_dir
- # chown $username:$username $ssh_dir
- fi
-
- # Check if the ssh public key is already loaded
- if ! grep -s -q "$public_key" $authorized_keys; then
- load_ssh_public_key
- # chmod 600 $authorized_keys
- # chown $username:$username $authorized_keys
- else
- log_action_msg "EC2: Already loaded ssh public key for user $username"
- fi
-else
- log_action_msg "
- == WARNING ==
- No ssh public key found!
- If you launch an instance without specifying a keypair,
- you can't connect to the instance.
- Please terminate this instance and launch a new EC2 instance.
-
- == IMPORTANT ==
- Don't forget to create a keypair or select an existing one
- before you launch the new instance"
-fi
-log_action_msg "EC2: -----END FETCH SSH PUBLIC KEY-----"
-
-# Tear down the config session
-$SHELL_API teardownSession
-if [ $? -ne 0 ]; then
- echo "An error occured while tearing down the session!"
- exit 0
-fi
-exit 0
diff --git a/scripts/ec2-check.pl b/scripts/ec2-check.pl
deleted file mode 100755
index 03448ff5..00000000
--- a/scripts/ec2-check.pl
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env perl
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 or later as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# This code was originally developed by VyOS Development Group
-# All Rights Reserved.
-#
-# Author: Daniil Baturin <daniil@baturin.org>
-# Description: Check if we are running on an EC2 instance.
-# If both system UUID and system serial number start with "EC2",
-# most likely we are.
-#
-# **** End License ****
-
-
-use strict;
-use warnings;
-
-my $DMIDECODE = "/usr/sbin/dmidecode";
-
-my $UUID = `$DMIDECODE -s system-uuid`;
-my $SN = `$DMIDECODE -s system-serial-number`;
-
-if( ($UUID =~ /^ec2.*/i) &&
- ($SN =~ /^ec2.*/i) )
-{
- exit(0);
-}
-else
-{
- exit(1);
-}
-
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index 62b7f80e..0acfcb1f 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -36,29 +36,6 @@ get_grub_index () {
fi
}
-# Check if installing on AWS EC2 AMI
-is_amazon_ec2_ami () {
- /opt/vyatta/sbin/ec2-check.pl
- if [ $? != 0 ]; then
- return 1
- fi
-
- ami_id_url=http://169.254.169.254/latest/meta-data/ami-id
-
- ami_id=$(/usr/bin/curl --silent "$ami_id_url")
- if [ -n "$ami_id" ]; then
- echo "Installing on VyOS AMI"
-
- # Create init script links for /etc/init.d/ec2-vyos-init
- chroot $INST_ROOT update-rc.d ec2-vyos-init defaults &>/dev/null
-
- # Dijkstra, forgive us!
- return 0
- else
- return 1
- fi
-}
-
if [ $(id -u) != 0 ]; then
echo "Image installation requires root privileges!"
exit 1
@@ -287,14 +264,6 @@ if [ -e "$DEF_GRUB" ]; then
mv $BOOT_DIR/%%default_image $BOOT_DIR/%%default_image.orig
ln -s $NEWNAME $BOOT_DIR/%%default_image
fi
-
- # Modify grub.cfg for AWS EC2 AMI
- if is_amazon_ec2_ami; then
- sed -i "/menuentry \"VyOS $NEWNAME (Serial/{N;N;N;N;d;}" $BOOT_DIR/grub/grub.cfg
- sed -i "/menuentry \"Lost password change $NEWNAME/{N;N;N;N;d;}" $BOOT_DIR/grub/grub.cfg
- sed -i "s/VyOS $NEWNAME (KVM console)/VyOS AMI (HVM) $NEWNAME/" $BOOT_DIR/grub/grub.cfg
- sed -i "s/$NEWNAME console=ttyS0.*/$NEWNAME console=ttyS0/" $BOOT_DIR/grub/grub.cfg
- fi
fi
logger -p local3.warning -t "SystemImage" "System Image $NEWNAME has been added and made the default boot image"