Skip to content

Instantly share code, notes, and snippets.

@TuserSheikh
Created April 21, 2019 03:24
Show Gist options
  • Save TuserSheikh/16c67182f46a9911e6632ba80c3a7590 to your computer and use it in GitHub Desktop.
Save TuserSheikh/16c67182f46a9911e6632ba80c3a7590 to your computer and use it in GitHub Desktop.
startup for ubuntu
#!/usr/bin/env bash
if [[ -z `grep "net.ipv6.conf.all.disable_ipv6 = 1" /etc/sysctl.conf` ]]; then
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
fi
sudo sysctl -p
sudo apt purge webbrowser-app firefox evolution thunderbird empathy
sudo apt autoremove --purge
if [ ! -e /etc/apt/sources.list.bak ]; then
sudo sed -i.bak -E "s/http:\/\/(.+\.)?archive\.ubuntu\.com\/ubuntu\//http:\/\/mirror\.dhakacom\.com\/ubuntu-archive\//" /etc/apt/sources.list
fi
sudo apt-get update -y
sudo apt-get install -y software-properties-common build-essential git curl wget fonts-beng apt-transport-https exfat-fuse exfat-utils
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo tee /etc/apt/sources.list.d/vscode.list <<EOF
deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main
EOF
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo tee /etc/apt/sources.list.d/mariadb.list <<EOF
# MariaDB 10.3 repository list - created 2019-04-10 10:52 UTC
# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64,arm64,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu bionic main
deb-src http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu bionic main
EOF
sudo add-apt-repository -y ppa:ondrej/php
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get install -y openssh-server openssh-sftp-server net-tools zsh vim code chromium-browser guake
sudo sed -i.bak "s/#UseDNS no/UseDNS no/" /etc/ssh/sshd_config
if [[ ! -e $HOME/.ssh/id_rsa.pub ]]; then
ssh-keygen -q -f $HOME/.ssh/id_rsa
fi
sudo apt-get install -y nginx imagemagick mariadb-server redis-server default-jdk oracle-java8-installer
sudo tee /etc/mysql/mariadb.conf.d/set-charset-collation.cnf <<EOF
# MariaDB-specific config file.
# Read by /etc/mysql/mariadb.cnf
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8mb4
[mysqld]
#
# * Character sets
#
# Default is Latin1, if you need UTF-8 set all this (also in client section)
#
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
bind_address = 0.0.0.0
EOF
systemctl daemon-reload
systemctl restart mysql
sudo update-alternatives --config java
if [[ -z `grep JAVA_HOME /etc/environment` ]]; then
echo 'JAVA_HOME="/usr/lib/jvm/java-8-oracle"' | sudo tee -a /etc/environment
fi
if [[ ! -e elasticsearch-6.2.2.deb ]]; then
wget https://assets.dev.deligram.com/dl/elasticsearch-6.2.2.deb
fi
sudo dpkg -i elasticsearch-6.2.2.deb
sudo sed -i.bak "/^#\(cluster\.name\:[[:blank:]]*[^[:blank:]]*\)/s//cluster.name: deligram/" /etc/elasticsearch/elasticsearch.yml
sudo sed -i "/^#\(node\.name\:[[:blank:]]*[^[:blank:]]*\)/s//node.name: node-1/" /etc/elasticsearch/elasticsearch.yml
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
# apt-cache pkgnames | grep php7.1
sudo apt-get install -y php7.1-fpm php7.1-xml php7.1-xsl php7.1-mbstring php7.1-readline php7.1-zip php7.1-mysql php7.1-sqlite3 php7.1-opcache php7.1-json php7.1-xmlrpc php7.1-curl php7.1-bz2 php7.1-imap php7.1-intl php7.1-bcmath php7.1-soap php7.1-mcrypt php7.1-gd php-imagick php-xdebug
export USER_NAME=`whoami`
export GIST_BASE="https://gist.githubusercontent.com/mnishihan/7f9bbf3351c122a2fceadf4c4ebe70c4/raw/b99a8951bb220b581408b5e04b6ec6f0a7e9cc73"
sudo sed -i.bak "s/user = www-data/user = ${USER_NAME}/" /etc/php/7.1/fpm/pool.d/www.conf
sudo sed -i "s/group = www-data/group = ${USER_NAME}/" /etc/php/7.1/fpm/pool.d/www.conf
sudo sed -i.bak "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.1/fpm/php.ini
sudo sed -i.bak "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.1/cli/php.ini
mkdir -p $HOME/workspace/sites/default/adminer $HOME/workspace/sites/laravel
sudo cp /var/www/html/index.nginx-debian.html $HOME/workspace/sites/default/index.html
sudo chown $USER_NAME:$USER_NAME $HOME/workspace/sites/default/index.html
wget -O $HOME/workspace/sites/default/adminer/index.php https://github.com/vrana/adminer/releases/download/v4.7.1/adminer-4.7.1-en.php
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.orig
sudo wget -O /etc/nginx/sites-available/default "${GIST_BASE}/nginx-default"
sudo sed -i "s/__HOME__/\/home\/${USER_NAME}/g" /etc/nginx/sites-available/default
sudo wget -O /etc/nginx/sites-available/laravel-sites "${GIST_BASE}/nginx-laravel-sites"
sudo sed -i "s/__HOME__/\/home\/${USER_NAME}/g" /etc/nginx/sites-available/laravel-sites
sudo ln -s /etc/nginx/sites-available/laravel-sites /etc/nginx/sites-enabled/
sudo tee /etc/php/7.1/mods-available/xdebug.ini <<EOF
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
; xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.idekey=123456789
EOF
sudo systemctl restart php7.1-fpm.service nginx.service
# install & configure mailcatcher
sudo apt-get install libsqlite3-dev ruby2.5-dev
sudo gem install mailcatcher
sudo tee /etc/systemd/system/mailcatcher.service <<EOF
[Unit]
Description=MailCatcher Service
After=network.service
[Service]
Type=simple
ExecStart=/usr/local/bin/mailcatcher --foreground --ip 0.0.0.0
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable mailcatcher.service
sudo systemctl start mailcatcher.service
# if [[ ! -d /opt/PhpStorm-183.5153.36 ]]; then
# if [[ ! -e PhpStorm-183.5153.36.tar.gz ]]; then
# wget https://assets.dev.deligram.com/dl/PhpStorm-183.5153.36.tar.gz
# fi
# tar -xzf PhpStorm-183.5153.36.tar.gz
# sudo mv PhpStorm-183.5153.36 /opt/
# fi
# # install discord deps
# sudo apt-get install -y libc++1 libc++abi1 clang libappindicator1 libindicator7
# if [[ ! -e discord-0.0.8.deb ]]; then
# wget https://assets.dev.deligram.com/dl/discord-0.0.8.deb
# fi
# sudo dpkg -i discord-0.0.8.deb
# if [[ ! -e insomnia_6.3.2_amd64.deb ]]; then
# wget https://assets.dev.deligram.com/dl/insomnia_6.3.2_amd64.deb
# fi
# sudo dpkg -i insomnia_6.3.2_amd64.deb
pushd `pwd`
cd /opt
sudo git clone https://github.com/mnishihan/dev-tld-resolver.git
cd dev-tld-resolver/src
sudo make
sudo make install
sudo sed -i.orig '/^\(hosts\:[[:blank:]]*[^[:blank:]]*\)/s//\1 dev_tld/' /etc/nsswitch.conf
if [[ -z `grep DEV_TLD_DOMAINS /etc/environment` ]]; then
echo "DEV_TLD_DOMAINS=dev,lrvl,local" | sudo tee -a /etc/environment
fi
# cd $HOME
# chsh -s `which zsh`
# wget -O .antigen.zsh https://raw.githubusercontent.com/zsh-users/antigen/develop/bin/antigen.zsh
# wget -O .zshrc "${GIST_BASE}/.zshrc"
# popd
mkdir -p $HOME/bin
wget -O composer-setup.php https://getcomposer.org/installer
php composer-setup.php --install-dir=$HOME/bin --filename=composer
chmod +x $HOME/bin/composer
rm -f composer-setup.php
$HOME/bin/composer global require "laravel/installer"
if [[ -z `grep '$HOME/.composer/vendor/bin' $HOME/.profile` ]]; then
tee $HOME/.profile <<EOF
if [ -d '$HOME/.composer/vendor/bin' ] ; then
PATH='$HOME/.composer/vendor/bin:$PATH'
fi
EOF
fi
if [[ -z `grep '$HOME/bin' $HOME/.profile` ]]; then
tee $HOME/.profile <<EOF
if [ -d '$HOME/bin' ] ; then
PATH='$HOME/bin:$PATH'
fi
EOF
fi
sudo apt-get install -f
sudo apt-get autoremove -y
# sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment