anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2019-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | SUDO='' |
| 19 | [[ $EUID -ne 0 ]] && SUDO=sudo |
| 20 | |
| 21 | install_run_pkg_deps() { |
| 22 | $SUDO apt-get update && $SUDO apt-get install -y \ |
| 23 | openssl \ |
| 24 | libidn11 \ |
| 25 | libgnutls30 \ |
| 26 | libsctp1 \ |
| 27 | openssh-server |
| 28 | } |
| 29 | |
| 30 | install_run_utils() { |
| 31 | $SUDO apt-get update && $SUDO apt-get install -y \ |
| 32 | jq \ |
| 33 | dnsutils \ |
| 34 | iproute2 \ |
| 35 | iputils-ping \ |
| 36 | tcpdump |
| 37 | } |
| 38 | |
| 39 | install_ssh_server() { |
| 40 | $SUDO mkdir /var/run/sshd |
| 41 | echo 'root:mypass' | chpasswd |
| 42 | sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 43 | sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd |
| 44 | echo "export VISIBLE=now" >> /etc/profile |
| 45 | } |
| 46 | |
| 47 | cleanup_image() { |
| 48 | $SUDO rm -rf /var/lib/apt/lists/* |
| 49 | } |
| 50 | |
| 51 | install_run_deps() { |
| 52 | install_run_pkg_deps |
| 53 | install_ssh_server |
| 54 | } |
| 55 | |
| 56 | (return 2>/dev/null) && echo "Sourced" && return |
| 57 | |
| 58 | set -o errexit |
| 59 | set -o pipefail |
| 60 | set -o nounset |
| 61 | |
| 62 | install_run_deps |
| 63 | echo "Dependency install completed" |