|
@ -1,40 +1,33 @@ |
|
|
#!/bin/bash |
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BASEDIR=$PWD |
|
|
BASEDIR=$PWD |
|
|
TAG=$(cat /opt/debian-bash/.semver_git_tag) |
|
|
|
|
|
|
|
|
REQUIRED_PKGS=(jq rsync file git) |
|
|
|
|
|
|
|
|
function usage { |
|
|
|
|
|
|
|
|
function usage() { |
|
|
echo 'usage: --host | --containers | --full | --one-container <CT_NAME>' |
|
|
echo 'usage: --host | --containers | --full | --one-container <CT_NAME>' |
|
|
exit -1 |
|
|
exit -1 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function install_host { |
|
|
|
|
|
|
|
|
function install_host() { |
|
|
echo "install on: $HOSTNAME" |
|
|
echo "install on: $HOSTNAME" |
|
|
echo ---------------------- |
|
|
echo ---------------------- |
|
|
|
|
|
|
|
|
[ `id -u` -ne 0 ] && echo 'root privilege required' && exit 1 |
|
|
|
|
|
|
|
|
|
|
|
# required packages jq |
|
|
|
|
|
/usr/bin/dpkg-query --status jq >/dev/null 2>&1 |
|
|
|
|
|
[ $? -ne 0 ] && /usr/bin/apt install -y jq |
|
|
|
|
|
|
|
|
|
|
|
# required packages rsync |
|
|
|
|
|
/usr/bin/dpkg-query --status rsync >/dev/null 2>&1 |
|
|
|
|
|
[ $? -ne 0 ] && /usr/bin/apt install -y rsync |
|
|
|
|
|
|
|
|
[ $(id -u) -ne 0 ] && echo 'root privilege required' && exit 1 |
|
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091 |
|
|
|
|
|
source "$BASEDIR/lib/functions.sh" |
|
|
|
|
|
idem_apt_install "${REQUIRED_PKGS[@]}" |
|
|
|
|
|
|
|
|
if [[ ! $BASEDIR == '/opt/debian-bash' ]]; then |
|
|
if [[ ! $BASEDIR == '/opt/debian-bash' ]]; then |
|
|
# download and filfull /opt/debian-bash, then run it from folder |
|
|
# download and filfull /opt/debian-bash, then run it from folder |
|
|
|
|
|
|
|
|
if [[ -L /opt/debian-bash ]]; then |
|
|
if [[ -L /opt/debian-bash ]]; then |
|
|
cd /opt/debian-bash |
|
|
|
|
|
./install.sh $PARAM1 |
|
|
|
|
|
|
|
|
cd /opt/debian-bash && ./install.sh "$PARAM1" |
|
|
exit 0 |
|
|
exit 0 |
|
|
else |
|
|
else |
|
|
|
|
|
|
|
|
rm -rf /opt/debian-bash |
|
|
rm -rf /opt/debian-bash |
|
|
TEMP=`mktemp -d` |
|
|
|
|
|
|
|
|
TEMP=$(mktemp -d) |
|
|
cd $TEMP |
|
|
cd $TEMP |
|
|
echo $TEMP |
|
|
echo $TEMP |
|
|
wget https://git.artcode.re/pvincent/debian-bash/archive/master.tar.gz |
|
|
wget https://git.artcode.re/pvincent/debian-bash/archive/master.tar.gz |
|
@ -56,8 +49,7 @@ function install_host { |
|
|
ORIGINAL="ORIGINAL" |
|
|
ORIGINAL="ORIGINAL" |
|
|
declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc) |
|
|
declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc) |
|
|
|
|
|
|
|
|
for i in "${arr[@]}" |
|
|
|
|
|
do |
|
|
|
|
|
|
|
|
for i in "${arr[@]}"; do |
|
|
if [ ! -f "$i.$ORIGINAL" ]; then |
|
|
if [ ! -f "$i.$ORIGINAL" ]; then |
|
|
|
|
|
|
|
|
echo "$i needs installation $(basename $i)" |
|
|
echo "$i needs installation $(basename $i)" |
|
@ -71,13 +63,13 @@ function install_host { |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function install_containers { |
|
|
|
|
|
|
|
|
function install_containers() { |
|
|
echo "install containers" |
|
|
echo "install containers" |
|
|
echo -------------------- |
|
|
echo -------------------- |
|
|
|
|
|
|
|
|
# install inside active LXC containers |
|
|
# install inside active LXC containers |
|
|
if [[ -f '/snap/bin/lxc' ]]; then |
|
|
if [[ -f '/snap/bin/lxc' ]]; then |
|
|
for container in `/snap/bin/lxc list --format=json | /bin/jq -r '.[] | select(.state.status == "Running") | .name'`; do |
|
|
|
|
|
|
|
|
for container in $(/snap/bin/lxc list --format=json | /bin/jq -r '.[] | select(.state.status == "Running") | .name'); do |
|
|
install_one_container $container |
|
|
install_one_container $container |
|
|
echo |
|
|
echo |
|
|
done |
|
|
done |
|
@ -85,7 +77,7 @@ function install_containers { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function install_one_container { |
|
|
|
|
|
|
|
|
function install_one_container() { |
|
|
CT=$1 |
|
|
CT=$1 |
|
|
echo "install container <$CT>" |
|
|
echo "install container <$CT>" |
|
|
echo ------------------------- |
|
|
echo ------------------------- |
|
@ -122,5 +114,3 @@ case $PARAM1 in |
|
|
usage |
|
|
usage |
|
|
;; |
|
|
;; |
|
|
esac |
|
|
esac |
|
|
|
|
|
|
|
|
|
|
|
|