3 # nat.sh - Script to create a NAT using LXC Container
4 # Designed to work on unprivileged Containers
5 # Copyright (C) 2019 Guus Sliepen <guus@meshlink.io>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # Read command-line arguments
25 echo "enter valid arguments"
30 update_cmd="apt-get update -y >> /dev/null"
31 echo "${update_cmd}" | lxc-attach -n ${container} --
37 install_cmd="apt-get install ${pkg_name} -y >> /dev/null"
38 echo "${install_cmd}" | lxc-attach -n ${container} --
41 echo "${pkg_name} installation failed in ${container} retrying to install again"
43 echo "${update_cmd}" | lxc-attach -n ${container} --
45 echo "${install_cmd}" | lxc-attach -n ${container} --
48 echo "${pkg_name} installation failed in ${container} container"
52 echo "Installed ${pkg_name} in container ${container}"