Option to change the ssh port used by images
This commit is contained in:
parent
a6f9fc17fd
commit
b5d62545be
Binary file not shown.
|
@ -79,6 +79,9 @@ GENERIC_IMAGE="yes"
|
||||||
# Whether to reduce the number of decisions during interactive install
|
# Whether to reduce the number of decisions during interactive install
|
||||||
MINIMAL_INSTALL="yes"
|
MINIMAL_INSTALL="yes"
|
||||||
|
|
||||||
|
# default SSH port
|
||||||
|
SSH_PORT=2222
|
||||||
|
|
||||||
while [[ $# > 1 ]]
|
while [[ $# > 1 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
|
@ -152,6 +155,10 @@ case $key in
|
||||||
shift
|
shift
|
||||||
MINIMAL_INSTALL="$1"
|
MINIMAL_INSTALL="$1"
|
||||||
;;
|
;;
|
||||||
|
--ssh|--sshport)
|
||||||
|
shift
|
||||||
|
SSH_PORT="$1"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# unknown option
|
# unknown option
|
||||||
;;
|
;;
|
||||||
|
@ -218,7 +225,8 @@ make $IMAGE_TYPE \
|
||||||
IMAGE_SIZE="$IMAGE_SIZE" \
|
IMAGE_SIZE="$IMAGE_SIZE" \
|
||||||
SSH_PUBKEY="$SSH_PUBKEY" \
|
SSH_PUBKEY="$SSH_PUBKEY" \
|
||||||
GENERIC_IMAGE="$GENERIC_IMAGE" \
|
GENERIC_IMAGE="$GENERIC_IMAGE" \
|
||||||
MINIMAL_INSTALL="$MINIMAL_INSTALL"
|
MINIMAL_INSTALL="$MINIMAL_INSTALL" \
|
||||||
|
SSH_PORT="$SSH_PORT"
|
||||||
|
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
echo $'Build failed'
|
echo $'Build failed'
|
||||||
|
@ -262,7 +270,7 @@ Image was created.
|
||||||
You will be able to log into it with:
|
You will be able to log into it with:
|
||||||
"
|
"
|
||||||
if [[ $IMAGE_TYPE != "virtualbox"* && $IMAGE_TYPE != "qemu"* ]]; then
|
if [[ $IMAGE_TYPE != "virtualbox"* && $IMAGE_TYPE != "qemu"* ]]; then
|
||||||
echo $" ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p 2222
|
echo $" ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT
|
||||||
|
|
||||||
Password: $PASSWORD
|
Password: $PASSWORD
|
||||||
"
|
"
|
||||||
|
|
|
@ -62,6 +62,9 @@ SSH_PUBKEY="no"
|
||||||
# Whether this is a generic image for mass redistribution on the interwebs
|
# Whether this is a generic image for mass redistribution on the interwebs
|
||||||
GENERIC_IMAGE="no"
|
GENERIC_IMAGE="no"
|
||||||
|
|
||||||
|
# default SSH port
|
||||||
|
SSH_PORT=2222
|
||||||
|
|
||||||
enable_eatmydata_override() {
|
enable_eatmydata_override() {
|
||||||
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
|
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
|
||||||
if [ -x $rootdir/usr/bin/eatmydata ] && \
|
if [ -x $rootdir/usr/bin/eatmydata ] && \
|
||||||
|
@ -176,7 +179,7 @@ following commands, then enter your details.
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_ssh() {
|
configure_ssh() {
|
||||||
sed -i "s/Port .*/Port 2222/g" $rootdir/etc/ssh/sshd_config
|
sed -i "s/Port .*/Port ${SSH_PORT}/g" $rootdir/etc/ssh/sshd_config
|
||||||
|
|
||||||
if [[ "$SSH_PUBKEY" != "no" ]]; then
|
if [[ "$SSH_PUBKEY" != "no" ]]; then
|
||||||
if [ ! -d $rootdir/home/$MY_USERNAME/.ssh ]; then
|
if [ ! -d $rootdir/home/$MY_USERNAME/.ssh ]; then
|
||||||
|
|
|
@ -52,6 +52,7 @@ export CONFIG_FILENAME
|
||||||
export SSH_PUBKEY
|
export SSH_PUBKEY
|
||||||
export GENERIC_IMAGE
|
export GENERIC_IMAGE
|
||||||
export MINIMAL_INSTALL
|
export MINIMAL_INSTALL
|
||||||
|
export SSH_PORT
|
||||||
|
|
||||||
# Locate vmdebootstrap program fetched in Makefile
|
# Locate vmdebootstrap program fetched in Makefile
|
||||||
basedir=`pwd`
|
basedir=`pwd`
|
||||||
|
@ -164,6 +165,7 @@ sudo sed -i "s|CONFIG_FILENAME=.*|CONFIG_FILENAME=${CONFIG_FILENAME}|g" $TEMP_CU
|
||||||
sudo sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" $TEMP_CUSTOMISE
|
||||||
sudo sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" $TEMP_CUSTOMISE
|
||||||
sudo sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" $TEMP_CUSTOMISE
|
||||||
|
sudo sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" $TEMP_CUSTOMISE
|
||||||
|
|
||||||
echo $"starting $VMDEBOOTSTRAP"
|
echo $"starting $VMDEBOOTSTRAP"
|
||||||
# Run vmdebootstrap script to create image
|
# Run vmdebootstrap script to create image
|
||||||
|
|
Loading…
Reference in New Issue