Last active
July 12, 2024 08:48
-
-
Save yohanesgultom/fbacf601ce49bd38363b to your computer and use it in GitHub Desktop.
Revisions
-
yohanesgultom revised this gist
May 15, 2021 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,8 @@ APP_DIR=$HOME/pmjkt BACKUP_DIR=$HOME/backup BACKUP_FINAL_PATH="$HOME/$DB_NAME-$DATE.tar.gz" echo "deleting old backup dir.." rm -Rf $BACKUP_DIR mkdir -p $BACKUP_DIR/nginx mkdir -p $BACKUP_DIR/mysql mkdir -p $BACKUP_DIR/app @@ -21,8 +23,10 @@ sudo mysqldump $DB_NAME | gzip -9 > $BACKUP_DIR/mysql/"$DB_NAME.sql.gz" echo "backing up app.." cp -r $APP_DIR $BACKUP_DIR/app find $BACKUP_DIR/app -name ".git" -type d -print0|xargs -0 rm -r -- echo "compressing to $BACKUP_FINAL_PATH.." cd $BACKUP_DIR tar -zcf $BACKUP_FINAL_PATH * echo "completed" -
yohanesgultom revised this gist
May 15, 2021 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash # Tested on Ubuntu 20 LTS DATE=$(date +'%Y%m%d%H%M') DB_NAME=pmjkt APP_DIR=$HOME/pmjkt BACKUP_DIR=$HOME/backup BACKUP_FINAL_PATH="$HOME/$DB_NAME-$DATE.tar.gz" mkdir -p $BACKUP_DIR/nginx mkdir -p $BACKUP_DIR/mysql mkdir -p $BACKUP_DIR/app echo "backing up nginx.." cp -R /etc/nginx/sites-available $BACKUP_DIR/nginx/ cp /etc/nginx/nginx.conf $BACKUP_DIR/nginx/ echo "backing up mysql.." sudo mysqldump $DB_NAME | gzip -9 > $BACKUP_DIR/mysql/"$DB_NAME.sql.gz" echo "backing up app.." cp -r $APP_DIR $BACKUP_DIR/app echo "compressing .." tar -zcf $BACKUP_FINAL_PATH $BACKUP_DIR echo "completed" -
yohanesgultom revised this gist
Feb 9, 2021 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #!/bin/bash # Simple script to switch between git global config & credential store # Assuming you are storing your config in "$HOME/.gitconfig-{profile_name}" # and credential in "$HOME/.git-credentials-{profile_name}", switch to it by calling # git-switch {profile_name} if [ "$#" -ne 1 ] then echo "usage: git-switch {profile}" else profile=$1 config_file="$HOME/.gitconfig-$profile" cred_file="$HOME/.git-credentials-$profile" if [[ -f "$config_file" && -f "$cred_file" ]] then rm $HOME/.gitconfig && cp $config_file $HOME/.gitconfig rm $HOME/.git-credentials && cp $cred_file $HOME/.git-credentials else [ ! -f "$config_file" ] && echo "$config_file does not exist" [ ! -f "$cred_file" ] && echo "$cred_file does not exist" fi fi -
yohanesgultom revised this gist
Jul 18, 2020 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/bin/bash LOCALDB=kasihkerja_wp REMOTEDB=wordpress REMOTESERVER=kasihkerja DBFILE=${LOCALDB}_$(date +'%Y%m%d%H%M') mysqldump -u root -p $LOCALDB | gzip -9 > $DBFILE.sql.gz scp $DBFILE.sql.gz $REMOTESERVER:~ ssh $REMOTESERVER << EOF gunzip $DBFILE.sql.gz sudo mysql -e "DROP DATABASE IF EXISTS $REMOTEDB" sudo mysql -e "CREATE DATABASE $REMOTEDB" sudo mysql $REMOTEDB < $DBFILE.sql EOF -
yohanesgultom revised this gist
May 16, 2020 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,26 @@ #!/bin/bash # Dump mysql database(s) and keep the limit of backup files by deleting older ones # to prevent password prompt by mysqldump create .my.cnf file in $HOME directory containing: # [mysqldump] # user=root # password=rootpassword now=$(date +"%Y%m%d%H%M%S") dirname="backup" maxfile=3 echo "Creating backup of all MySQL databases.." mkdir -p "$dirname" # single database dbname="mgps" bak_file="$dbname.$now.sql.gz" mysqldump "$dbname" | gzip -9 > "$dirname/$bak_file" # all databases # bak_file="all-databases.$now.sql.gz" # mysqldump --all-databases --single-transaction | gzip -9 > "$dirname/$bak_file" echo "Backup file created: $bak_file" # This will list our file by modification time and delete all but the 3 most recent -
yohanesgultom revised this gist
Mar 24, 2020 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/bin/sh # Find file with $findpattern recursively in $findpath # Execute $cmd $file where for all files found # # Usage example: # ./batch_process.sh "/var/www/yohanes/wp-content/uploads" "*.png" "optipng" # ./batch_process.sh "/var/www/yohanes/wp-content/uploads" "*.jpg" "jpegoptim" # # @Author: [email protected] findpath=$1 findpattern=$2 cmd=$3 : ${findpath:="."} find "$findpath" -name "$findpattern" | while read f ; do eval "$cmd $f" done -
yohanesgultom revised this gist
Mar 9, 2020 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,15 @@ #!/bin/bash # Delete uploads leaving the $maxfile most recent files dirname="static/uploads" maxfile=$1 printf "maxfile=$maxfile\n" maxfile=$((maxfile+1)) purging=$(ls -dt "$dirname"/* | tail -n +"$maxfile"); if [ "$purging" != "" ]; then printf "Purging old directories:\n$purging\n"; rm -rf $purging; else printf "No directory found for purging at this time\n"; fi -
yohanesgultom revised this gist
Dec 13, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,12 +15,13 @@ MAXFILE=3 # Do not edit codes below unless you know what you are doing WP_PLUGINS="$WP_HOME/wp-content/plugins" WP_THEMES="$WP_HOME/wp-content/themes" WP_UPLOADS="$WP_HOME/wp-content/uploads" WP_CONFIG="$WP_HOME/wp-config.php" # Create WP backup with relative path tar --transform="s,^${WP_HOME:1}/,," --show-transformed -cvf $BACKUP_DIR/$FILE $WP_PLUGINS $WP_THEMES $WP_UPLOADS $WP_CONFIG && # Create WP database backup using credentials from .my.cnf and add it to archive mysqldump $DB_NAME > $BACKUP_DIR/$DB_FILE && -
yohanesgultom revised this gist
Dec 13, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ tar --transform="s,^${WP_HOME:1}/,," --show-transformed -cvf $BACKUP_DIR/$FILE $ mysqldump $DB_NAME > $BACKUP_DIR/$DB_FILE && # Append the dump to the archive, remove the dump and gzip the whole archive tar --transform="s,^${BACKUP_DIR:1},database," --show-transformed --append --file=$BACKUP_DIR/$FILE $BACKUP_DIR/$DB_FILE && gzip -9 $BACKUP_DIR/$FILE && # Delete DB file -
yohanesgultom revised this gist
Dec 13, 2019 . 1 changed file with 43 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #!/bin/bash # Wordpress backup script # Author: [email protected], 2019 # Change variables below according to your setup NOW=$(date +"%Y%m%d%H%M%S") FILE="yohanes.gultom.me.$NOW.tar" BACKUP_DIR="/home/yohanesgultom/backups/yohanes" WP_HOME="/var/www/yohanes" DB_NAME="wordpress" DB_FILE="yohanes.gultom.me.$NOW.sql" MAXFILE=3 # Do not edit codes below unless you know what you are doing WP_THEMES="$WP_HOME/wp-content/themes" WP_UPLOADS="$WP_HOME/wp-content/uploads" WP_CONFIG="$WP_HOME/wp-config.php" # Create WP backup with relative path tar --transform="s,^${WP_HOME:1}/,," --show-transformed -cvf $BACKUP_DIR/$FILE $WP_THEMES $WP_UPLOADS $WP_CONFIG && # Create WP database backup using credentials from .my.cnf and add it to archive mysqldump $DB_NAME > $BACKUP_DIR/$DB_FILE && # Append the dump to the archive, remove the dump and gzip the whole archive tar --transform="s,^${WP_HOME:1},database," --show-transformed --append --file=$BACKUP_DIR/$FILE $BACKUP_DIR/$DB_FILE && gzip -9 $BACKUP_DIR/$FILE && # Delete DB file rm $BACKUP_DIR/$DB_FILE # This will list our file by modification time and delete all but the MAXFILE most recent MAXFILE=$((MAXFILE+1)) purging=$(ls -dt "$BACKUP_DIR"/* | tail -n +"$MAXFILE"); if [ "$purging" != "" ]; then echo Purging old file: $purging; rm -rf $purging; else echo "No file found for purging at this time"; fi -
yohanesgultom revised this gist
Oct 6, 2019 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ #!/bin/bash # set PUBLIC_IP env variable with current instance IP to be used in docker-compose configuration date && export PUBLIC_IP=$(/usr/bin/curl http://checkip.amazonaws.com) && cd /home/ubuntu/condor_cloud && /usr/bin/docker-compose down -v && /usr/bin/docker-compose up -d -
yohanesgultom revised this gist
Jul 23, 2019 . 2 changed files with 0 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +0,0 @@ -
yohanesgultom revised this gist
Mar 6, 2019 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/bin/bash # UPDATE: 2019-03-06 Turns out single zip for each language is available at http://wpaorg.wordproject.com/bibles/app/audio/{LANG_ID}.zip :p # Politely (sequentially) downloading bible audio from WordProject website # Usage: ./wordproject_audio_bible_download.sh [START] [END] [DELAY] # START: first bible book code eg. Genesis -> 1, Exodus -> 2, Matthew -> 40, Revelation -> 66 # END: last bible book code eg. Genesis -> 1, Exodus -> 2, Matthew -> 40, Revelation -> 66 # DELAY: delay time in second between download # @Author [email protected] START=$1 END=$2 DELAY=$3 BASE_URL="http://wpaorg.wordproject.com/bibles/app/audio" BASE_DIR="$HOME/Audio/ALKITAB_TB_WORDPROJECT_ORG" LANG_ID="14" for (( i=$START; i<=$END; i++ )) do n=$(printf %03d $i) wget -c -O "${BASE_DIR}/${LANG_ID}_${n}.zip" "${BASE_URL}/${LANG_ID}_${i}.zip" sleep $DELAY done -
yohanesgultom revised this gist
Dec 14, 2018 . 2 changed files with 21 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/bin/bash # Dump mysql database and keep the limit of backup files by deleting older ones # to prevent password prompt by mysqldump create .my.cnf file in $HOME directory containing: # [mysqldump] # user=root @@ -8,7 +8,20 @@ dbname="mgps" now=$(date +"%Y%m%d%H%M%S") bak_file="$dbname.$now.sql.gz" dirname="backup" maxfile=3 echo "Creating backup of all MySQL databases.." mkdir -p "$dirname" mysqldump "$dbname" | gzip -9 > "$dirname/$bak_file" echo "Backup file created: $bak_file" # This will list our file by modification time and delete all but the 3 most recent $((maxfile++)) purging=$(ls -dt "$dirname"/* | tail -n +"$maxfile"); if [ "$purging" != "" ]; then echo Purging old file: $purging; rm -rf $purging; else echo "No file found for purging at this time"; fi This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,14 @@ #!/bin/bash # Delete all leaving the $maxfile most recent files dirname="backup" maxfile=3 $((maxfile++)) purging=$(ls -dt "$dirname"/* | tail -n +"$maxfile"); if [ "$purging" != "" ]; then echo Purging old file: $purging; rm -rf $purging; else echo "No file found for purging at this time"; fi -
yohanesgultom revised this gist
Dec 14, 2018 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,10 @@ # user=root # password=rootpassword dbname="mgps" now=$(date +"%Y%m%d%H%M%S") bak_file="$dbname.$now.sql.gz" echo "Creating backup of all MySQL databases.." mysqldump "$dbname" | gzip -9 > "$bak_file" echo "Backup file created: $bak_file" -
yohanesgultom revised this gist
Jul 24, 2018 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ composer install composer dump-autoload sudo -u www-data php artisan config:cache sudo -u www-data php artisan route:cache sudo -u www-data php artisan view:cache sudo -u www-data php artisan queue:restart -
yohanesgultom revised this gist
Jul 12, 2018 . 1 changed file with 44 additions and 40 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,67 +1,71 @@ #!/bin/sh # tested on debian 9 x64 # some commands require user inputs (eg. password) # configuration # repo="https://bitbucket.org/yohanesgultom/ucds2" # install basic tools apt-get update apt install sudo locales-all zip curl git -y # create sudo user adduser dev usermod -aG sudo dev # ssh-copy-id [email protected] su dev sudo dpkg-reconfigure tzdata locale-gen # setup tomcat curl -s "https://get.sdkman.io" | bash source ~/.sdkman/bin/sdkman-init.sh sdk install java 7.0.181-zulu echo "export JAVA_HOME=/home/dev/.sdkman/candidates/java/7.0.181-zulu" >> ~/.bashrc source ~/.bashrc wget http://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.90/bin/apache-tomcat-7.0.90.tar.gz tar -zxvf apache-tomcat-7.0.90.tar.gz rm -Rf apache-tomcat-7.0.90/webapps/* # setup db echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc source ~/.bashrc sudo apt-get install postgresql -y sudo pg_createcluster 9.3 main --start # if autostart is not working sudo -i -u postgres createdb sirsak sudo -i -u postgres createuser --no-superuser --pwprompt sirsak sudo -i -u postgres psql -c "grant all privileges on database sirsak to sirsak;" # setup grails sdk install grails 2.2.1 # setup app git clone https://bitbucket.org/yohanesgultom/ucds2 sirsak cp ucds2/.sirsak.groovy . cd sirsak grails dev war dist/sirsak.war cp dist/sirsak.war /home/dev/apache-tomcat-7.0.90/webapps/ROOT.war # start/stop tomcat /home/dev/apache-tomcat-7.0.90/bin/startup.sh # /home/dev/apache-tomcat-7.0.90/bin/shutdown.sh # setup routing sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 # sudo nano /etc/rc.local # add autorestart job crontab -l > editcron echo "0 0 * * * /home/ubuntu/deploylatest.sh" >> editcron crontab editcron rm editcron sudo service cron restart # OPTIONAL (just in case) install missing plugins cd ~/.sdkman/candidates/grails/2.2.1/plugins/ wget -O resources-1.2.14.zip https://grails.org/plugins/grails-resources/tags/RELEASE_1.2.14/grails-resources-1.2.14.zip wget -O resources-1.2.14.pom https://grails.org/plugins/grails-resources/tags/RELEASE_1.2.14/grails-resources-1.2.14.pom wget -O excel-export-0.2.1.zip https://grails.org/plugins/grails-excel-export/tags/RELEASE_0.2.1/grails-excel-export-0.2.1.zip wget -O excel-export-0.2.1.pom https://grails.org/plugins/grails-excel-export/tags/RELEASE_0.2.1/grails-excel-export-0.2.1.pom wget -O shiro-1.1.4.zip https://grails.org/plugins/grails-shiro/tags/RELEASE_1.1.4/grails-shiro-1.1.4.zip wget -O shiro-1.1.4.pom https://grails.org/plugins/grails-shiro/tags/RELEASE_1.1.4/grails-shiro-1.1.4.pom -
yohanesgultom revised this gist
Mar 6, 2018 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -58,4 +58,14 @@ cp "$dir/deploylatest.sh" ~ ./deploylatest.sh # forward port 80 to 8080 sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 # append on /etc/rc.local to be run automatically on startup sudo service tomcat7 start sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 # (optional) firewall setting (fail2ban is already installed by default) sudo ufw allow ssh sudo ufw allow www sudo ufw allow 8080 sudi ufw enable -
yohanesgultom revised this gist
Mar 6, 2018 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -55,3 +55,7 @@ git config --global user.name $gitusername git config --global credential.helper store git clone "$repo" "$dir" cp "$dir/deploylatest.sh" ~ ./deploylatest.sh # forward port 80 to 8080 sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 -
yohanesgultom revised this gist
Mar 6, 2018 . 2 changed files with 58 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin CATALINA_HOME=/var/lib/tomcat7 start() { sudo $CATALINA_HOME/bin/startup.sh This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ # Tested on Ubuntu 16 x64 # configuration dir="ucds2" repo="https://bitbucket.org/yohanesgultom/ucds2" gitusername="Yohanes Gultom" gitemail="[email protected]" dbname="sirsak" dbuser="sirsak" # main script # create sudo user adduser "$dbuser" usermod -aG sudo "$dbuser" # ssh-copy-id [email protected] su "$dbuser" sudo dpkg-reconfigure tzdata sudo apt-get update # setup tomcat wget http://www-eu.apache.org/dist/tomcat/tomcat-7/v7.0.85/bin/apache-tomcat-7.0.85.tar.gz sudo tar xzvf apache-tomcat-7.0.85.tar.gz -C /var/lib sudo mv /var/lib/apache-tomcat-7.0.85 /var/lib/tomcat7 sudo nano /etc/init.d/tomcat7 # copy paste content of `tomcat7.init.d` sudo chmod 755 /etc/init.d/tomcat7 sudo update-rc.d tomcat7 defaults # install java sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-7-jdk echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bashrc source ~/.bashrc # setup db sudo locale-gen echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc source ~/.bashrc sudo apt-get install postgresql -y #sudo pg_createcluster 9.5 main --start # if autostart is not working sudo -i -u postgres createdb "$dbname" sudo -i -u postgres createuser --no-superuser --pwprompt "$dbuser" sudo -i -u postgres psql -c "grant all privileges on database $dbname to $dbuser;" # setup grails sudo apt-get install zip -y curl -s "https://get.sdkman.io" | bash source ~/.sdkman/bin/sdkman-init.sh sdk install grails 2.2.1 # setup app sudo apt-get install git -y git config --global user.email $gitemail git config --global user.name $gitusername git config --global credential.helper store git clone "$repo" "$dir" cp "$dir/deploylatest.sh" ~ -
yohanesgultom revised this gist
Feb 11, 2018 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ #!/bin/bash # This will list our file by modification time and delete all but the 3 most recent purging=$(ls -dt somedir/* | tail -n +3); if [ "$purging" != "" ]; then echo Purging old file: $purging; rm -rf $purging; else echo "No file found for purging at this time"; fi -
yohanesgultom revised this gist
Nov 18, 2017 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/bin/bash now=$(date +"%Y%m%d%H%M%S") db=mydb username=secret password=secret # backup to temp dir mongodump -u $username -p $password --db $db --excludeCollection sessions --excludeCollection jobs --out "$HOME/backups/$now" && # compress tar -zcvf "$HOME/backups/mongo-$now.tar.gz" "$HOME/backups/$now" && # delete tmp dir rm -Rf "$HOME/backups/$now" -
yohanesgultom revised this gist
Sep 12, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,7 @@ dbuser="sirsak" # create sudo user adduser "$dbuser" usermod -aG sudo "$dbuser" # ssh-copy-id [email protected] su "$dbuser" sudo apt-get update # setup tomcat -
yohanesgultom revised this gist
Aug 29, 2017 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ sudo apt-get update sudo apt-get install tomcat7 -y sudo apt-get install openjdk-7-jdk -y echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> ~/.bashrc # setup db locale-gen echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc @@ -29,18 +30,30 @@ sudo pg_createcluster 9.3 main --start # if autostart is not working sudo -i -u postgres createdb "$dbname" sudo -i -u postgres createuser --no-superuser --pwprompt "$dbuser" sudo -i -u postgres psql -c "grant all privileges on database $dbname to $dbuser;" # setup grails sudo apt-get install zip -y curl -s "https://get.sdkman.io" | bash source ~/.sdkman/bin/sdkman-init.sh sdk install grails 2.2.1 # setup app sudo apt-get install git -y git config --global user.email $gitemail git config --global user.name $gitusername git config --global credential.helper store git clone "$repo" "$dir" cp "$dir/deploylatest.sh" ~ # install missing plugins cd ~/.sdkman/candidates/grails/2.2.1/plugins/ wget -O resources-1.2.14.zip https://grails.org/plugins/grails-resources/tags/RELEASE_1.2.14/grails-resources-1.2.14.zip wget -O resources-1.2.14.pom https://grails.org/plugins/grails-resources/tags/RELEASE_1.2.14/grails-resources-1.2.14.pom wget -O excel-export-0.2.1.zip https://grails.org/plugins/grails-excel-export/tags/RELEASE_0.2.1/grails-excel-export-0.2.1.zip wget -O excel-export-0.2.1.pom https://grails.org/plugins/grails-excel-export/tags/RELEASE_0.2.1/grails-excel-export-0.2.1.pom wget -O shiro-1.1.4.zip https://grails.org/plugins/grails-shiro/tags/RELEASE_1.1.4/grails-shiro-1.1.4.zip wget -O shiro-1.1.4.pom https://grails.org/plugins/grails-shiro/tags/RELEASE_1.1.4/grails-shiro-1.1.4.pom # setup routing sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 # set timezone -
yohanesgultom revised this gist
Aug 29, 2017 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,25 +17,25 @@ usermod -aG sudo "$dbuser" su "$dbuser" sudo apt-get update # setup tomcat sudo apt-get install tomcat7 -y sudo apt-get install openjdk-7-jdk -y echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> ~/.bashrc # setup db locale-gen echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc source ~/.bashrc sudo apt-get install postgresql -y sudo pg_createcluster 9.3 main --start # if autostart is not working sudo -i -u postgres createdb "$dbname" sudo -i -u postgres createuser --no-superuser --pwprompt "$dbuser" sudo -i -u postgres psql -c "grant all privileges on database $dbname to $dbuser;" # setup grails sudo apt-get install zip -y curl -s "https://get.sdkman.io" | bash source ~/.sdkman/bin/sdkman-init.sh sdk install grails 2.2.1 # setup app sudo apt-get install git -y git config --global user.email $gitemail git config --global user.name $gitusername git config --global credential.helper store -
yohanesgultom revised this gist
Jul 17, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # Copied from https://gist.github.com/dougalsutherland/266983/9c88f1ca1cf1420af03166dcfccb9cb10a21c110 #!/bin/bash exts=".aux .lof .log .lot .fls .out .toc .dvi .bbl .bcf .blg -blx.aux -blx.bib -blx.bib .run.xml .fdb_latexmk .synctex.gz .syntex.gz(busy) .pdfsync .algorithms .alg .loa .thm .nav .snm .vrb .acn .acr .glg .glo .gls .brf .lol .idx .ilg .ind .ist .maf .mtc .mtc0 .pyg .nlo .tdo .xdy .keys" -
yohanesgultom revised this gist
Jul 17, 2017 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/bin/bash exts=".aux .lof .log .lot .fls .out .toc .dvi .bbl .bcf .blg -blx.aux -blx.bib -blx.bib .run.xml .fdb_latexmk .synctex.gz .syntex.gz(busy) .pdfsync .algorithms .alg .loa .thm .nav .snm .vrb .acn .acr .glg .glo .gls .brf .lol .idx .ilg .ind .ist .maf .mtc .mtc0 .pyg .nlo .tdo .xdy .keys" for x in "${@:-.}"; do arg=$(echo ${x:-.} | perl -pe 's/\.(tex|pdf)$//') if [[ -d "$arg" ]]; then for ext in $exts; do rm -f "$arg"/*$ext done else for ext in $exts; do rm -f "$arg"$ext done fi done rm -rf $(biber --cache) # gross biber bug -
yohanesgultom revised this gist
Jun 12, 2017 . 1 changed file with 11 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,36 +11,38 @@ dbname="sirsak" dbuser="sirsak" # main script # create sudo user adduser "$dbuser" usermod -aG sudo "$dbuser" su "$dbuser" sudo apt-get update # setup tomcat sudo apt-get install tomcat7 sudo apt-get install openjdk-7-jdk echo "export JAVA_HOME=/usr/lib/jvm/default-java" >> ~/.bashrc # setup db locale-gen echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc source ~/.bashrc sudo apt-get install postgresql sudo pg_createcluster 9.3 main --start # if autostart is not working sudo -i -u postgres createdb "$dbname" sudo -i -u postgres createuser --no-superuser --pwprompt "$dbuser" sudo -i -u postgres psql -c "grant all privileges on database $dbname to $dbuser;" # setup grails sudo apt-get install zip curl -s "https://get.sdkman.io" | bash source ~/.sdkman/bin/sdkman-init.sh sdk install grails 2.2.1 # setup app sudo apt-get install git git config --global user.email $gitemail git config --global user.name $gitusername git config --global credential.helper store git clone "$repo" "$dir" cp "$dir/deploylatest.sh" ~ # setup routing sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080 # set timezone sudo dpkg-reconfigure tzdata # add autorestart job -
yohanesgultom revised this gist
Jun 12, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,7 @@ dbuser="sirsak" # main script adduser sirsak apt-get update # setup tomcat apt-get install tomcat7 -
yohanesgultom revised this gist
May 2, 2017 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ #!/bin/bash # to prevent password prompt by mysqldump create .my.cnf file in $HOME directory containing: # [mysqldump] # user=root # password=rootpassword now=$(date +"%Y%m%d%H%M%S") bak_file="backup.$now.sql" bak_file_gz="$bak_file.gz" echo "Creating backup of all MySQL databases.." time mysqldump --all-databases --single-transaction > "$bak_file" tar zcvf "$bak_file_gz" "$bak_file" rm "$bak_file" echo "Backup file created: $bak_file_gz"
NewerOlder