Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use the following command to install it in your enviroment:
sudo apt-get update && apt-get install -y wget

# This downloads an installation script and run it
wget -O - https://release.choco-technologies.com/scripts/install-choco-scripts.sh | bash
wget -O - https://raw.githubusercontent.com/JohnAmadis/choco-scripts/main/install-choco-scripts.sh | bash
```

Once the scripts are installed, they are auto-loaded on bash start and you can start using it. To import it in your script, just add the following line into your project:
Expand Down
5 changes: 3 additions & 2 deletions install-choco-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#

PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
GITHUB_REPO=JohnAmadis/choco-scripts
VERSION=latest
FILE_NAME=choco-scripts-$VERSION.tar.gz
URL=http://release.choco-technologies.com/scripts/$FILE_NAME
URL=https://github.com/$GITHUB_REPO/releases/latest/download/$FILE_NAME
TARGET_PATH=~/.choco-scripts
TEMPLATE_FILE_NAME=template.sh
TEMPLATE_FILE_PATH=$TARGET_PATH/$TEMPLATE_FILE_NAME
Expand All @@ -20,7 +21,7 @@ CHOCO_HELP_FILE_PATH=$TARGET_PATH/$CHOCO_HELP_FILE_NAME
USER_CONFIG_PATH=~/.choco-scripts.cfg
BASHRC_FILE_PATH=~/.bashrc
ENTRY_SCRIPT_NAME=choco-scripts
INSTALL_URL=https://release.choco-technologies.com/scripts/install-choco-scripts.sh
INSTALL_URL=https://raw.githubusercontent.com/$GITHUB_REPO/main/install-choco-scripts.sh

if [ "$1" == "--help" ]
then
Expand Down
28 changes: 27 additions & 1 deletion public/template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,40 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
CONFIGURATION_FILE_PATH=~/.choco-scripts.cfg
SCRIPT_DESCRIPTION=""

#
# Installs choco-scripts
#
function installChocoScripts()
{
echo "Installation of the choco-scripts"

# This line installs wget tool - you don't need to use it if you already have it
apt-get update && apt-get install -y wget

# This downloads an installation script and run it
wget -O - https://raw.githubusercontent.com/JohnAmadis/choco-scripts/main/install-choco-scripts.sh | bash
}

#
# Verification of the choco scripts installation
#
if [ -f "$CONFIGURATION_FILE_PATH" ]
then
source $CONFIGURATION_FILE_PATH
else
printf "\033[31;1mChoco-Scripts are not installed for this user\033[0m\n"
printf "\033[31;1mChoco-Scripts are not installed for this user\033[0m\n\n"
printf " \033[37;1mYou can find the installation instruction here: \033[0m\n"
printf " \033[34;1mhttps://github.com/JohnAmadis/choco-scripts\033[0m\n\n"

while true
do
read -p "Do you want to try to auto-install it? [Y/n]: " answer
case $answer in
[Yy]* ) installChocoScripts; break;;
[Nn]* ) echo "Skipping installation"; exit 1;;
* ) echo "Please answer Y or n";;
esac
done
exit 1
fi

Expand Down