Last active
August 29, 2015 14:15
-
-
Save Alanaktion/02cdebdce34f2b75ef86 to your computer and use it in GitHub Desktop.
Auto-setup an Ubuntu machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sets up a new Ubuntu installation with good things | |
# Desktop and Server are supported | |
# Detect Ubuntu version | |
distro="server" | |
(dpkg -s "ubuntu-desktop" && distro="ubuntu") > /dev/null 2>&1 | |
(dpkg -s "xubuntu-desktop" && distro="xubuntu") > /dev/null 2>&1 | |
(dpkg -s "kubuntu-desktop" && distro="kubuntu") > /dev/null 2>&1 | |
# Declare basic functions | |
function install { | |
/usr/bin/sudo /usr/bin/apt-get install $1 -y &> /dev/null | |
} | |
function alert { | |
if [[ $distro != "server" && -f "/usr/bin/notify-send" ]]; then | |
/usr/bin/notify-send $1 $2 | |
else | |
echo $1 $2 | |
fi | |
} | |
# Enable passwordless sudo | |
if [[ $USER != 'root' ]]; then | |
echo -n "Enable passwordless sudo for current user (y/n)? [n] " | |
read pwdless | |
if [[ $pwdless == 'y' ]]; then | |
/usr/bin/sudo /bin/bash -c "echo '$USER ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers" | |
echo "Passwordless sudo enabled for $USER" | |
else | |
echo "Skipping passwordless sudo." | |
fi | |
fi | |
# Update package list and upgrade system | |
echo "Updating packages list..." | |
/usr/bin/sudo /usr/bin/apt-get update &> /dev/null | |
echo "Installing system updates..." | |
/usr/bin/sudo /usr/bin/apt-get upgrade -y &> /dev/null | |
alert "Package updates were installed." "Additional upgrades for the kernal and core applications may be available." | |
# Install core applications | |
echo "Installing core applications..." | |
if [[ $distro != "server" ]]; then | |
install pidgin synaptic htop vim cmatrix git gitk | |
alert "New applications installed!" "Pidgin, Synaptic, git, vim, htop, and cmatrix" | |
else | |
install htop vim cmatrix git | |
echo "Installed git, vim, htop, and cmatrix" | |
fi | |
echo | |
# Install a web server | |
echo -n "What web server would you like (apache2/nginx)? [none] " | |
read server | |
if [[ $server == 'apache2' ]]; then | |
install apache2 mysql-server mysql-client php5 php5-cli php5-mysql php5-gd php5-curl php5-mcrypt php5-json php5-imap libnusoap-php | |
# Configure server | |
/usr/bin/sudo a2enmod rewrite | |
/usr/bin/sudo php5enmod mcrypt | |
/usr/bin/sudo perl -pi -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/apache2/php.ini | |
# Make new web root | |
/usr/bin/sudo mkdir -p /var/www | |
/usr/bin/sudo chown $USER:www-data /var/www | |
# Restart service | |
/usr/bin/sudo service apache2 restart | |
alert "Web server installed!" "Apache/PHP5/MySQL" | |
elif [[ $server == 'nginx' ]]; then | |
install nginx mysql-server mysql-client php5-fpm php5-cli php5-mysql php5-gd php5-curl php5-mcrypt php5-json php5-imap libnusoap-php | |
# Configure server | |
/usr/bin/sudo php5enmod mcrypt | |
/usr/bin/sudo perl -pi -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/php5-fpm/php.ini | |
# Make new web root | |
/usr/bin/sudo mkdir -p /var/www | |
/usr/bin/sudo chown $USER:www-data /var/www | |
# Restart Service | |
/usr/bin/sudo service php5-fpm restart | |
alert "Web server installed!" "NGINX/PHP5/MySQL" | |
else | |
echo "Skipping web server." | |
fi | |
# Install gnome as an alternative to Unity | |
if [[ $distro == "ubuntu" ]]; then | |
install gnome-session-fallback | |
alert "Installed Gnome as an alternative to Unity." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment