automatic

This commit is contained in:
Alexandre
2021-12-08 11:21:12 +01:00
parent a495b1aec2
commit 45061e0f83

View File

@@ -1,6 +1,5 @@
#!/bin/bash
echo "AUTOMATIC PACKAGES SELECTION"
set +u
set +e 2>/dev/null
##################
# INIT VARIABLES #
@@ -16,13 +15,13 @@ PACKMANAGER="apk"
if [[ "$(apk -h 2>/dev/null)" ]]; then
# If apk based
PACKMANAGER="apk"
echo "yes"
echo "yes"
PACKAGES="apk add --no-cache $PACKAGES"
else
# If apt-get based
PACKMANAGER="apt"
echo "no"
echo "no"
PACKAGES="apt-get clean \
&& apt-get update \
&& apt-get install -y $PACKAGES"
fi
###################
@@ -37,27 +36,33 @@ PACKAGES="$PACKAGES jq curl"
# FOR EACH SCRIPT, SELECT PACKAGES
##################################
if ls /etc/cont-init.d/*smb_mounts* 1> /dev/null 2>&1; then
for files in "/scripts" "/etc/cont-init.d" "/etc"; do
if ls $files/*smb* 1> /dev/null 2>&1; then
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba samba-client"
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba smbclient"
fi
if ls /etc/cont-init.d/*vpn* 1> /dev/null 2>&1; then
if ls $files/*vpn* 1> /dev/null 2>&1; then
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
fi
if ls /etc/cont-init.d/*global_var* 1> /dev/null 2>&1; then
if ls $files/*global_var* 1> /dev/null 2>&1; then
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES jq"
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES jq"
fi
if ls /etc/cont-init.d/*yaml* 1> /dev/null 2>&1; then
if ls $files/*yaml* 1> /dev/null 2>&1; then
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES yamllint"
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES yamllint"
fi
if ls /etc/*nginx* 1> /dev/null 2>&1; then
if ls $files/*nginx* 1> /dev/null 2>&1; then
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES nginx"
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES nginx"
fi
done
# Create file containing all packages to install
echo "$PACKAGES" >> /packages
echo "$PACKAGES"