test
This commit is contained in:
parent
41493df3c7
commit
52a5aede4d
@ -3,8 +3,7 @@ echo "Checking Dependencies"
|
||||
|
||||
## Script Location
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
|
||||
apt update
|
||||
source "$SCRIPTDIR/common/functions.sh"
|
||||
|
||||
## Start File Loop
|
||||
## For .dependency files In The dependencies Directory
|
||||
@ -12,24 +11,24 @@ DEPENDENCIESALL="$SCRIPTDIR/dependencies/*.dep"
|
||||
for f in $DEPENDENCIESALL
|
||||
do
|
||||
## Name Of Package
|
||||
DEPENDENCYNAME=$(echo "`basename $f | cut -f 1 -d '.'`")
|
||||
DEPENDENCYCOMMAND=$(echo "`basename $f | cut -f 1 -d '.'`")
|
||||
## Actual Package
|
||||
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
|
||||
echo "** $DEPENDENCYNAME Is Already Installed."
|
||||
echo "** $DEPENDENCYCOMMAND Is Already Installed."
|
||||
else
|
||||
echo "** Installing $DEPENDENCYNAME"
|
||||
apt install -y $DEPENDENCYPACKAGE
|
||||
echo "** Installing $DEPENDENCYCOMMAND"
|
||||
install_pkg $DEPENDENCYPACKAGE
|
||||
fi
|
||||
|
||||
if which $DEPENDENCYNAME >/dev/null;
|
||||
if is_command $DEPENDENCYCOMMAND;
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "** Error Installing $DEPENDENCYNAME"
|
||||
echo "** Error Installing $DEPENDENCYCOMMAND"
|
||||
fi
|
||||
## End Of loop
|
||||
done
|
||||
|
||||
@ -3,6 +3,7 @@ echo "Checking For Custom MOTD"
|
||||
|
||||
## Script Location
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
source "$SCRIPTDIR/common/functions.sh"
|
||||
|
||||
## Start File Loop
|
||||
## For .dependency files In The dependencies Directory
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
echo "Checking Topgrade Situation"
|
||||
|
||||
## Script Location
|
||||
# SCRIPTDIR=$(dirname $0)
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
source "$SCRIPTDIR/common/functions.sh"
|
||||
|
||||
echo "* Checking for topgrade directory"
|
||||
topgrade_install_directory="/opt/topgrade"
|
||||
@ -38,14 +39,7 @@ fi
|
||||
echo "checking for topgrade confs"
|
||||
custom_topgrade_confs_path="/etc/topgrade"
|
||||
custom_topgrade_confs_git="https://git.deathbybandaid.net/deathbybandaid/topgrade.git"
|
||||
if [ ! -d "$custom_topgrade_confs_path" ]; then
|
||||
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
|
||||
|
||||
git_update "topgrade" "$custom_topgrade_confs_path" "$custom_topgrade_confs_git"
|
||||
|
||||
## Update
|
||||
if [ -f "$topgrade_binary" ]; then
|
||||
|
||||
@ -2,19 +2,14 @@
|
||||
echo "Checking Custom Bash Aliases"
|
||||
|
||||
## Script Location
|
||||
# SCRIPTDIR=$(dirname $0)
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
source "$SCRIPTDIR/common/functions.sh"
|
||||
|
||||
BASHRCFILE="$HOME/.bashrc"
|
||||
|
||||
custom_bash_aliases_path="/etc/bash_aliases"
|
||||
custom_bash_aliases_git="https://git.deathbybandaid.net/deathbybandaid/bash_aliases.git"
|
||||
if [ ! -d "$custom_bash_aliases_path" ]; then
|
||||
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
|
||||
git_update "topgrade" "$custom_bash_aliases_path" "$custom_bash_aliases_git"
|
||||
|
||||
echo "* Checking if bash aliases are setup in ~/.bashrc"
|
||||
if [[ $(grep -L "$custom_bash_aliases_path" $BASHRCFILE) ]]; then
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
echo "Checking IPA Realm Join Status"
|
||||
|
||||
## Script Location
|
||||
# SCRIPTDIR=$(dirname $0)
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
source "$SCRIPTDIR/common/functions.sh"
|
||||
|
||||
|
||||
# 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
|
||||
echo "* git Is Already Installed."
|
||||
else
|
||||
echo "* Running Update command and Installing git"
|
||||
echo "* Installing git"
|
||||
install_pkg git
|
||||
fi
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ echo "Setting up template environment"
|
||||
|
||||
## Script Location
|
||||
SCRIPTDIR=$(dirname $0)
|
||||
# SCRIPTREPO="https://git.deathbybandaid.net/deathbybandaid/template_setup.git"
|
||||
git -C $SCRIPTDIR pull
|
||||
echo ""
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user