Skip to content

Instantly share code, notes, and snippets.

@jcchikikomori
Last active June 14, 2019 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcchikikomori/3449f3538c64c15c26ba4b10365243df to your computer and use it in GitHub Desktop.
Save jcchikikomori/3449f3538c64c15c26ba4b10365243df to your computer and use it in GitHub Desktop.
XAMPP Local Setup for Linux. Fixes htdocs
#!/bin/bash
LAMPP_DIR="/opt/lampp"
XAMPP_DIR="c:/xampp"
LAMPP=$LAMPP_DIR/lampp
# Get OS type
case "$OSTYPE" in
cygwin*)
OS=Windows
;;
linux*)
OS=Linux
;;
darwin*)
OS=OSX
;;
*)
echo -e "\e[1;32mUnable to identify OS type $OSTYPE...\e[0m"
echo -e "\e[1;31mPress ENTER to continue...\e[0m"
read
exit
;;
esac
function lampp_setup {
sudo $LAMPP stop
echo -e "Checking htdocs/ directory.."
# ls -l $LAMPP_DIR/htdocs
HTDOCS=$LAMPP_DIR/htdocs
# echo -e $USER
# echo -e $CURRENT_USER
echo -e "Setting htdocs/ permissions (chmod)"
sudo chmod -R 755 $HTDOCS
echo -e "Setting htdocs/ permissions to user (chown)"
sudo chown -R 1000:1000 $HTDOCS
read -p "Do you want to set XAMPP env now? (y/n) " choice0
# switch/case
case "$choice0" in
y|Y )
set_envs
;;
* )
echo -p "Skipping.."
;;
esac
start_xampp
}
function set_envs {
echo -e "Setting XAMPP ENV to global is currently WIP"
}
function start_xampp {
read -p "Do you want to start XAMPP now? (y/n) " choice1
# switch/case
case "$choice1" in
y|Y )
sudo $LAMPP start
exit
;;
n|N )
exit
;;
* )
echo -p "Skipping.."
exit
;;
esac
}
# Check if Linux
if [ "$OS" == "Linux" ]; then
# Do this
printf "\033c" # Clear screen
echo -e "============================================"
echo -e "XAMPP for Linux"
echo -e "Permission script for Local Development"
echo -e "Expected dir: \e[1;31m$LAMPP_DIR\e[0m"
echo -e "============================================"
# Remove this
echo -e "\e[1;31mPress ENTER to begin, or cancel to exit\e[0m"
read
# root check
if [ "$EUID" -ne 0 ]; then
lampp_setup
fi
else
echo -e "ERROR: This script is for Linux version of XAMPP.."
read
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment