modified dependency script to allow for git repos

This commit is contained in:
Josh Ashton
2024-02-12 17:46:10 -07:00
parent 434e484ad0
commit eed993baa0
3 changed files with 94 additions and 67 deletions
+44 -14
View File
@@ -1,15 +1,5 @@
#!/bin/zsh #!/bin/zsh
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <command> <package>"
echo "Checks if a command is installed and if not, installs the package."
echo "Supported package managers: apt, pacman, dnf, yum, brew, port"
exit 1
fi
COMMAND=$1
PACKAGE=$2
error() { error() {
echo "Your package manager is not supported." echo "Your package manager is not supported."
echo "$COMMAND could not be installed automatically." echo "$COMMAND could not be installed automatically."
@@ -17,8 +7,12 @@ error() {
exit 1 exit 1
} }
if ! command -v $COMMAND &> /dev/null install() {
then COMMAND=$1
PACKAGE=$2
if ! command -v $COMMAND &> /dev/null
then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "$COMMAND not found. Installing $PACKAGE..." echo "$COMMAND not found. Installing $PACKAGE..."
@@ -47,7 +41,7 @@ then
fi fi
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Command not found. Installing $COMMAND..." echo "$COMMAND not found. Installing $PACKAGE..."
if command -v "brew" &> /dev/null if command -v "brew" &> /dev/null
then then
@@ -64,6 +58,42 @@ then
else else
error error
fi fi
else else
echo "Package $PACKAGE which provides the command $COMMAND, is already installed." echo "Package $PACKAGE which provides the command $COMMAND, is already installed."
fi
}
# If the number of arguments is not 2, print the usage
if [[ $# -ne 2 ]]; then
echo "Usage: check-dependency <command> <package>"
echo " check-dependency <--git> <user/repo>"
echo "Checks if a command is installed and if not, installs the package."
echo "If --git is specified, it will check if the git repository is executable."
echo "Supported package managers: apt, pacman, dnf, yum, brew, port"
exit 1
fi
COMMAND=$1
PACKAGE=$2
# If the command is git, we will clone the repository and install it
if $COMMAND == "--git"; then
USER=$(echo $PACKAGE | cut -d'/' -f1)
REPO=$(echo $PACKAGE | cut -d'/' -f2)
# If the repository is not installed, we will clone it and install it
if ! command -v $REPO &> /dev/null
then
cd /tmp
git clone https://github.com/$USER/$REPO
cd $REPO
inst
exit 0
else
echo "Repository $PACKAGE is already installed."
exit 0
fi
else
install $COMMAND $PACKAGE
fi fi
+13 -12
View File
@@ -94,9 +94,9 @@ install_python() {
# Create the executable # Create the executable
sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE
sudo echo "\nsource $ENV" >> /usr/local/bin/$EXECUTABLE sudo echo "source $ENV" >> /usr/local/bin/$EXECUTABLE
sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE
sudo echo "\n# Auto-generated by the install script" >> /usr/local/bin/$NAME sudo echo "# Auto-generated by the install script" >> /usr/local/bin/$EXECUTABLE
sudo chmod +x /usr/local/bin/$EXECUTABLE sudo chmod +x /usr/local/bin/$EXECUTABLE
success "$NAME" "$EXECUTABLE" success "$NAME" "$EXECUTABLE"
@@ -185,33 +185,34 @@ check_sudo() {
} }
check_theme() { check_theme() {
if ! -d ~/.config USER=$SUDO_USER
if [ ! -d /home/$USER/.config ];
then then
echo "Creating the ~/.config directory..." echo "Creating the ~/.config directory..."
su $SUDO_USER -c "mkdir ~/.config" su $USER -c "mkdir /home/$USER/.config"
fi fi
if ! -d ~/.config/theme if [ ! -d /home/$USER/.config/theme ];
then then
echo "Creating the ~/.config/theme directory..." echo "Creating the /home/$USER/.config/theme directory..."
su $SUDO_USER -c "mkdir ~/.config/theme" su $USER -c "mkdir /home/$USER/.config/theme"
fi fi
THEME_DIR=~/.config/theme THEME_DIR=/home/$USER/.config/theme
if ! -f ~/.config/theme/active.theme if [ ! -f $THEME_DIR/active.theme ];
then then
su $SUDO_USER -c "touch $THEME_DIR/light.theme" su $USER -c "touch $THEME_DIR/light.theme"
echo "base=#C6CAED" > $THEME_DIR/light.theme echo "base=#C6CAED" > $THEME_DIR/light.theme
echo "accent=#4D5382" >> $THEME_DIR/light.theme echo "accent=#4D5382" >> $THEME_DIR/light.theme
echo "hover=#262940" >> $THEME_DIR/light.theme echo "hover=#262940" >> $THEME_DIR/light.theme
su $SUDO_USER -c "touch $THEME_DIR/dark.theme" su $USER -c "touch $THEME_DIR/dark.theme"
echo "base=#262940" > $THEME_DIR/dark.theme echo "base=#262940" > $THEME_DIR/dark.theme
echo "accent=#4D5382" >> $THEME_DIR/dark.theme echo "accent=#4D5382" >> $THEME_DIR/dark.theme
echo "hover=#C6CAED" >> $THEME_DIR/dark.theme echo "hover=#C6CAED" >> $THEME_DIR/dark.theme
su $SUDO_USER -c "ln -s $THEME_DIR/dark.theme $THEME_DIR/active.theme" su $USER -c "ln -s $THEME_DIR/dark.theme $THEME_DIR/active.theme"
fi fi
} }
-4
View File
@@ -1,4 +0,0 @@
#!/bin/zsh
su $SUDO_USER -c "mkdir src"
mkdir build