Merge remote-tracking branch 'origin/master' into merge-branch

Change-Id: I05cc51c699008018d557ed3874d71af26fd60240
This commit is contained in:
Ian Wienand 2016-11-29 07:17:04 +11:00
commit 448a2602fe
35 changed files with 100 additions and 11 deletions

View File

@ -85,10 +85,15 @@ for i in $(find $ELEMENTS_DIR -type f \
error "$i is not executable" error "$i is not executable"
fi fi
# Ensure 4 spaces indent are used # run flake8 over python files. note our "dib-python"
if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]]; then # interpreter can confuse the magic matching being done in
# "file" and make it think the file is not python;
# special-case it.
if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]] || \
[[ $firstline =~ "dib-python" ]]; then
flake8 $i || error "$i failed flake8" flake8 $i || error "$i failed flake8"
else else
# Ensure 4 spaces indent are used
if ! excluded indent ; then if ! excluded indent ; then
indent_regex='^\( \{4\}\)* \{1,3\}[^ ]' indent_regex='^\( \{4\}\)* \{1,3\}[^ ]'
if grep -q "$indent_regex" ${i}; then if grep -q "$indent_regex" ${i}; then

View File

@ -53,7 +53,7 @@ case "$ARCH" in
qemu_binary_file="/usr/bin/qemu-arm-static" qemu_binary_file="/usr/bin/qemu-arm-static"
copy_binary $qemu_binary_file $ARCH copy_binary $qemu_binary_file $ARCH
;; ;;
"arm64") "arm64" | "aarch64")
qemu_binary_file="/usr/bin/qemu-aarch64-static" qemu_binary_file="/usr/bin/qemu-aarch64-static"
copy_binary $qemu_binary_file $ARCH copy_binary $qemu_binary_file $ARCH
;; ;;

View File

@ -1 +1,2 @@
debian-minimal debian-minimal
openssh-server

View File

@ -1,4 +1,3 @@
openssh-server:
file: file:
less: less:
kbd: kbd:

View File

@ -1,3 +1,3 @@
dib-init-system dib-init-system
install-static install-static
package-installs openssh-server

View File

@ -1 +0,0 @@
openssh-server:

View File

@ -0,0 +1,14 @@
==============
openssh-server
==============
This element ensures that openssh server is installed and enabled during boot.
Note
----
Most cloud images come with the openssh server service installed and enabled
during boot. However, certain cloud images, especially those created by the
\*-minimal elements may not have it installed or enabled. In these cases,
using this element may be helpful to ensure your image will accessible via SSH.
It's usually helpful to combine this element with others such as the
`runtime-ssh-host-keys`.

View File

@ -0,0 +1,3 @@
dib-init-system
package-installs
runtime-ssh-host-keys

View File

@ -0,0 +1,10 @@
{
"family": {
"suse": {
"openssh-server": "openssh"
},
"gentoo": {
"openssh-server": "openssh"
}
}
}

View File

@ -0,0 +1,29 @@
#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
case "$DIB_INIT_SYSTEM" in
upstart)
# nothing to do
exit 0
;;
systemd)
if [[ $DISTRO_NAME = "ubuntu" || $DISTRO_NAME = "debian" ]]; then
systemctl enable ssh.service
else
systemctl enable sshd.service
fi
;;
openrc)
# let dib-init-system's postinstall handle enabling init scripts
exit 0
;;
*)
echo "Unsupported init system"
exit 1
;;
esac

View File

@ -101,3 +101,8 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
# Tell emacs to use python-mode
# Local variables:
# mode: python
# End:

View File

@ -1 +1 @@
package-installs openssh-server

View File

@ -18,6 +18,9 @@ elif [[ "$ARCH" = "ppc64" ]]; then
elif [[ "$ARCH" = "ppc64el" ]]; then elif [[ "$ARCH" = "ppc64el" ]]; then
basearch=ppc64el basearch=ppc64el
arch=ppc64el arch=ppc64el
elif [[ "$ARCH" = "aarch64" ]]; then
basearch=aarch64
arch=aarch64
else else
echo "********************" echo "********************"
echo "Unknown arch '$ARCH'" echo "Unknown arch '$ARCH'"

View File

@ -12,10 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# dib-lint: disable=dibdebugtrace # dib-lint: disable=dibdebugtrace setpipefail
set -exu set -exu
set -o pipefail
# We are running into race conditions with glean, which ssh-keygen -A is # We are running into race conditions with glean, which ssh-keygen -A is
# not handling properly. So, create a new script to first check if the # not handling properly. So, create a new script to first check if the
@ -23,7 +22,7 @@ set -o pipefail
for key in dsa ecdsa ed25519 rsa; do for key in dsa ecdsa ed25519 rsa; do
FILE=/etc/ssh/ssh_host_${key}_key FILE=/etc/ssh/ssh_host_${key}_key
if ! [ -e $FILE ]; then if ! [ -f $FILE ]; then
/usr/bin/yes n | /usr/bin/ssh-keygen -f $FILE -N '' -t $key /usr/bin/yes n | /usr/bin/ssh-keygen -f $FILE -N '' -t $key
fi fi
done done

View File

@ -242,7 +242,17 @@ else
sudo -E chroot $TARGET_ROOT ${YUM} -y update sudo -E chroot $TARGET_ROOT ${YUM} -y update
sudo -E chroot $TARGET_ROOT ${YUM} -y \ sudo -E chroot $TARGET_ROOT ${YUM} -y \
--setopt=cachedir=/tmp/yum/$ARCH/$DIB_RELEASE \ --setopt=cachedir=/tmp/yum/$ARCH/$DIB_RELEASE \
install passwd findutils sudo util-linux-ng install systemd passwd findutils sudo util-linux-ng
# This package is split out from systemd on >F24, dracut is
# missing the dependency and will fail to make an initrd without
# it; see
# https://bugzilla.redhat.com/show_bug.cgi?id=1398505
if [ $DISTRO_NAME = "fedora" -a $DIB_RELEASE -ge 24 ]; then
sudo -E chroot $TARGET_ROOT ${YUM} -y \
--setopt=cachedir=/tmp/yum/$ARCH/$DIB_RELEASE \
install systemd-udev
fi
# Put in a dummy /etc/resolv.conf over the temporary one we used # Put in a dummy /etc/resolv.conf over the temporary one we used
# to bootstrap. systemd has a bug/feature [1] that it will assume # to bootstrap. systemd has a bug/feature [1] that it will assume

View File

@ -26,6 +26,8 @@ else
"armv"*) "armv"*)
_ARCH="armhf" _ARCH="armhf"
;; ;;
"aarch64")
;;
*) *)
echo "WARNING: Unknown architecture: $_ARCH" echo "WARNING: Unknown architecture: $_ARCH"
;; ;;

View File

@ -143,6 +143,10 @@ function eval_run_d () {
} }
function kill_chroot_processes () { function kill_chroot_processes () {
local xtrace
xtrace=$(set +o | grep xtrace)
set +o xtrace
if [ -z "${1}" ]; then if [ -z "${1}" ]; then
echo "ERROR: no chroot directory specified" echo "ERROR: no chroot directory specified"
exit 1 exit 1
@ -157,6 +161,8 @@ function kill_chroot_processes () {
sudo kill $pid sudo kill $pid
fi fi
done done
$xtrace
} }
function cleanup_build_dir () { function cleanup_build_dir () {

View File

@ -0,0 +1,4 @@
---
features:
- New openssh-server element to ensure that the openssh
server is installed and enabled during boot.