test
This commit is contained in:
parent
41493df3c7
commit
52a5aede4d
@ -3,8 +3,7 @@ echo "Checking Dependencies"
|
|||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
source "$SCRIPTDIR/common/functions.sh"
|
||||||
apt update
|
|
||||||
|
|
||||||
## Start File Loop
|
## Start File Loop
|
||||||
## For .dependency files In The dependencies Directory
|
## For .dependency files In The dependencies Directory
|
||||||
@ -12,24 +11,24 @@ DEPENDENCIESALL="$SCRIPTDIR/dependencies/*.dep"
|
|||||||
for f in $DEPENDENCIESALL
|
for f in $DEPENDENCIESALL
|
||||||
do
|
do
|
||||||
## Name Of Package
|
## Name Of Package
|
||||||
DEPENDENCYNAME=$(echo "`basename $f | cut -f 1 -d '.'`")
|
DEPENDENCYCOMMAND=$(echo "`basename $f | cut -f 1 -d '.'`")
|
||||||
## Actual Package
|
## Actual Package
|
||||||
DEPENDENCYPACKAGE=`cat $f`
|
DEPENDENCYPACKAGE=`cat $f`
|
||||||
echo "* Checking For $DEPENDENCYNAME with package name $DEPENDENCYPACKAGE"
|
echo "* Checking For command $DEPENDENCYCOMMAND with package name $DEPENDENCYPACKAGE"
|
||||||
|
|
||||||
if which $DEPENDENCYNAME >/dev/null;
|
if is_command $DEPENDENCYCOMMAND;
|
||||||
then
|
then
|
||||||
echo "** $DEPENDENCYNAME Is Already Installed."
|
echo "** $DEPENDENCYCOMMAND Is Already Installed."
|
||||||
else
|
else
|
||||||
echo "** Installing $DEPENDENCYNAME"
|
echo "** Installing $DEPENDENCYCOMMAND"
|
||||||
apt install -y $DEPENDENCYPACKAGE
|
install_pkg $DEPENDENCYPACKAGE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which $DEPENDENCYNAME >/dev/null;
|
if is_command $DEPENDENCYCOMMAND;
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
echo "** Error Installing $DEPENDENCYNAME"
|
echo "** Error Installing $DEPENDENCYCOMMAND"
|
||||||
fi
|
fi
|
||||||
## End Of loop
|
## End Of loop
|
||||||
done
|
done
|
||||||
|
|||||||
@ -3,6 +3,7 @@ echo "Checking For Custom MOTD"
|
|||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
source "$SCRIPTDIR/common/functions.sh"
|
||||||
|
|
||||||
## Start File Loop
|
## Start File Loop
|
||||||
## For .dependency files In The dependencies Directory
|
## For .dependency files In The dependencies Directory
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
echo "Checking Topgrade Situation"
|
echo "Checking Topgrade Situation"
|
||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
# SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
source "$SCRIPTDIR/common/functions.sh"
|
||||||
|
|
||||||
echo "* Checking for topgrade directory"
|
echo "* Checking for topgrade directory"
|
||||||
topgrade_install_directory="/opt/topgrade"
|
topgrade_install_directory="/opt/topgrade"
|
||||||
@ -38,14 +39,7 @@ fi
|
|||||||
echo "checking for topgrade confs"
|
echo "checking for topgrade confs"
|
||||||
custom_topgrade_confs_path="/etc/topgrade"
|
custom_topgrade_confs_path="/etc/topgrade"
|
||||||
custom_topgrade_confs_git="https://git.deathbybandaid.net/deathbybandaid/topgrade.git"
|
custom_topgrade_confs_git="https://git.deathbybandaid.net/deathbybandaid/topgrade.git"
|
||||||
if [ ! -d "$custom_topgrade_confs_path" ]; then
|
git_update "topgrade" "$custom_topgrade_confs_path" "$custom_topgrade_confs_git"
|
||||||
echo "** Installing topgrade configs"
|
|
||||||
git clone --quiet $custom_topgrade_confs_git $custom_topgrade_confs_path
|
|
||||||
else
|
|
||||||
echo "** Updating topgrade configs"
|
|
||||||
git -C $custom_topgrade_confs_path pull
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
if [ -f "$topgrade_binary" ]; then
|
if [ -f "$topgrade_binary" ]; then
|
||||||
|
|||||||
@ -2,19 +2,14 @@
|
|||||||
echo "Checking Custom Bash Aliases"
|
echo "Checking Custom Bash Aliases"
|
||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
# SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
source "$SCRIPTDIR/common/functions.sh"
|
||||||
|
|
||||||
BASHRCFILE="$HOME/.bashrc"
|
BASHRCFILE="$HOME/.bashrc"
|
||||||
|
|
||||||
custom_bash_aliases_path="/etc/bash_aliases"
|
custom_bash_aliases_path="/etc/bash_aliases"
|
||||||
custom_bash_aliases_git="https://git.deathbybandaid.net/deathbybandaid/bash_aliases.git"
|
custom_bash_aliases_git="https://git.deathbybandaid.net/deathbybandaid/bash_aliases.git"
|
||||||
if [ ! -d "$custom_bash_aliases_path" ]; then
|
git_update "topgrade" "$custom_bash_aliases_path" "$custom_bash_aliases_git"
|
||||||
echo "* Installing Bash Aliases"
|
|
||||||
git clone --quiet $custom_bash_aliases_git $custom_bash_aliases_path
|
|
||||||
else
|
|
||||||
echo "* Updating Bash Aliases"
|
|
||||||
git -C $custom_bash_aliases_path pull
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "* Checking if bash aliases are setup in ~/.bashrc"
|
echo "* Checking if bash aliases are setup in ~/.bashrc"
|
||||||
if [[ $(grep -L "$custom_bash_aliases_path" $BASHRCFILE) ]]; then
|
if [[ $(grep -L "$custom_bash_aliases_path" $BASHRCFILE) ]]; then
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
echo "Checking IPA Realm Join Status"
|
echo "Checking IPA Realm Join Status"
|
||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
# SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
source "$SCRIPTDIR/common/functions.sh"
|
||||||
|
|
||||||
|
|
||||||
# TODO setup /etc/hosts with FQDN and FreeIPA servers
|
# TODO setup /etc/hosts with FQDN and FreeIPA servers
|
||||||
|
|||||||
67
common/functions.sh
Normal file
67
common/functions.sh
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
is_command() {
|
||||||
|
local check_command="$1"
|
||||||
|
command -v "${check_command}" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
git_update() {
|
||||||
|
local git_name="$1"
|
||||||
|
local git_path="$2"
|
||||||
|
local git_repo="$3"
|
||||||
|
if [ ! -d "$git_path" ]; then
|
||||||
|
echo "* Installing $git_name"
|
||||||
|
git clone --quiet $git_repo $git_path
|
||||||
|
else
|
||||||
|
echo "* Updating $git_name"
|
||||||
|
git -C $git_path pull
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
should_apt_last_update() {
|
||||||
|
LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
|
||||||
|
UNIX_TIME=$( date +%s )
|
||||||
|
TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))
|
||||||
|
if [[ "${TIME_DIFF}" -gt 43200 ]]
|
||||||
|
then
|
||||||
|
# 0 = true
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
# 1 = false
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_pkg_mgr() {
|
||||||
|
if is_command apt-get ; then
|
||||||
|
echo "apt-get"
|
||||||
|
elif is_command rpm ; then
|
||||||
|
# Then check if dnf or yum is the package manager
|
||||||
|
if is_command dnf ; then
|
||||||
|
echo "dnf"
|
||||||
|
else
|
||||||
|
echo "yum"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_pkg() {
|
||||||
|
|
||||||
|
# package to install
|
||||||
|
local pkg_to_install="$1"
|
||||||
|
|
||||||
|
# Get Command language
|
||||||
|
PKG_MANAGER=$( get_pkg_mgr )
|
||||||
|
|
||||||
|
# Run apt-get update for distros that use apt-get
|
||||||
|
if [ "$PKG_MANAGER" == "apt-get" ] ; then
|
||||||
|
if should_apt_last_update ; then
|
||||||
|
"${PKG_MANAGER} update"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install the package
|
||||||
|
local PKG_INSTALL=("${PKG_MANAGER}" install -y)
|
||||||
|
|
||||||
|
"${PKG_INSTALL[@]}" "${pkg_to_install}"
|
||||||
|
}
|
||||||
@ -71,7 +71,7 @@ if is_command git;
|
|||||||
then
|
then
|
||||||
echo "* git Is Already Installed."
|
echo "* git Is Already Installed."
|
||||||
else
|
else
|
||||||
echo "* Running Update command and Installing git"
|
echo "* Installing git"
|
||||||
install_pkg git
|
install_pkg git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ echo "Setting up template environment"
|
|||||||
|
|
||||||
## Script Location
|
## Script Location
|
||||||
SCRIPTDIR=$(dirname $0)
|
SCRIPTDIR=$(dirname $0)
|
||||||
# SCRIPTREPO="https://git.deathbybandaid.net/deathbybandaid/template_setup.git"
|
|
||||||
git -C $SCRIPTDIR pull
|
git -C $SCRIPTDIR pull
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user