Skip to content

Instantly share code, notes, and snippets.

@naryal2580
Last active December 14, 2021 08:26
Show Gist options
  • Save naryal2580/c643f3e3d353226aa68721e9f86b5560 to your computer and use it in GitHub Desktop.
Save naryal2580/c643f3e3d353226aa68721e9f86b5560 to your computer and use it in GitHub Desktop.
Download and install XAMPP in supported Linux and OSX distro.
#!/bin/bash
random_dir="/tmp/$RANDOM"
mkdir $random_dir && cd random_dir
download_xampp_installer(grep_keyword) {
echo -e "Downloading XAMPP Installer..\n"
wget $(wget -q -O - https://www.apachefriends.org/index.html | grep $grep_keyword | cut -d '"' -f 6) 2> /dev/null
if [ ! -f ./xampp-*-installer.run ]; then
curl -o "./xampp-linux-installer.run" $(curl -s https://www.apachefriends.org/index.html | grep $grep_keyword | cut -d '"' -f 6)
else
echo "Please install either of \x1b[1mcurl\x1b[0m or \x1b[1mwget\x1b[0m."
exit 1
fi
}
if [[ $OSTYPE == 'darwin'* ]]; then
download_xampp_installer "xampp-osx"
chmod +x ./xampp-osx-*-vm.dmg
echo -e "\nLaunching XAMPP OSX Installer."
sudo ./xampp-osx-*-vm.dmg
elif [[ $OSTYPE == 'linux'* ]]; then
download_xampp_installer "xampp-linux-*-installer\.run"
chmod +x ./xampp-linux-*-installer.run
echo -e "\nLaunching XAMPP Linux Installer."
sudo ./xampp-linux-*-installer.run
else
echo "The following Operating System isn't supported by this specific script."
fi
cd - && rm -rf $random_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment