Skip to content

Instantly share code, notes, and snippets.

View danitfk's full-sized avatar

danitfk danitfk

View GitHub Profile
#!/bin/bash -x
# Global variables
taskFile="/tmp/.task.txt"
function taskAdd {
echo "Task Add"
checkTaskfile
# Check if task name is not empty
checkString=$(echo $@ | sed 's/add//g')
@danitfk
danitfk / convert.sh
Last active September 23, 2019 15:12
Fix directory path in OpenCart DirectAdmin to cPanel
#!/bin/bash
# Change /home directory if it's different
for filename in $(find /home/ -maxdepth 6 -name "config.php" | grep -E "public_html/config.php|public_html/admin/config.php")
do
echo "Filename: $filename"
for string in $(grep domains $filename | cut -d"," -f2 | cut -d\' -f2)
do
domain=$(echo $string | grep -o domains.* | cut -d/ -f2)
correct=$(echo $string | sed 's|domains/||g' | sed "s|/$domain||g")
ips="10.233.64.0
10.233.65.0
10.233.70.0
10.233.71.0
10.233.66.0
10.233.69.0
10.233.67.0
10.233.68.0
10.233.73.0
10.233.72.0"
#!/usr/bin/python
"""smtptest.py: command-line smtp test mail sender
https://github.com/turbodog/python-smtp-mail-sending-tester
Usage: python smtptest.py [options] fromaddress toaddress serveraddress
Examples:
python smtptest.py bob@example.com mary@example.com mail.example.com
python smtptest.py --debuglevel 1 --usetls -u bob -p xyzzy "Bob <bob@example.com>" mary@example.com mail.example.com
@danitfk
danitfk / docker-compose.yml
Last active June 12, 2019 07:02
Elkarbackup production grade docker-compose
version: '3'
services:
elkarbackup:
image: elkarbackup/elkarbackup:1.3.1-apache
environment:
SYMFONY__DATABASE__PASSWORD: "mysecurepass@"
EB_CRON: "enabled"
volumes:
- /backup:/app/backups
#!/bin/bash
LOADAVG=$(cat /proc/loadavg | awk {'print $3'} | cut -d. -f1)
SERVICES="mysql
httpd"
if [ "$LOADAVG" -gt 10 ]; then
for service in $SERVICES
do
echo "Restart $service"
systemctl restart $service
#!/bin/bash
for i in `ls /sys/class/scsi_device/`
do
echo 1 > /sys/class/scsi_device/`echo $i | sed 's|:|\:|g'`/device/rescan
done
for i in `ls /sys/class/scsi_host/`
do
echo "- - -" > /sys/class/scsi_host/$i/scan
@danitfk
danitfk / pgsql_backup.sh
Last active October 20, 2018 17:30 — forked from sirbrillig/pgsql_backup.sh
Postgresql daily backup script.
#!/bin/bash
#
# Backup a Postgresql database into a daily file.
#
BACKUP_DIR="$1"
DAYS_TO_KEEP=14
FILE_SUFFIX=_pg_backup_jira.sql
DATABASE=jira
USER=postgres
@danitfk
danitfk / check-jira.sh
Created September 16, 2018 13:41
A Simple bash script to check Jira process based on "jps" tool.
#!/bin/bash
# Specify Atlassian Jira username (tomcat)
JIRAUSER="jira"
if [[ "$(sudo su $JIRAUSER -c 'jps -v'| grep "jira" | awk {'print $1'})" -gt "0" ]]
then
echo "1"
else
echo "0"
fi
@danitfk
danitfk / Bash Script cheat sheet
Last active November 14, 2018 10:09
It's my own cheat sheet to write bash scripts easily.
# Variables
IP=`ifconfig | grep inet | awk {'print $2'} | grep -Ev "127.0.0.1|:"`
### Ask y/n question
printf "Question? (y/n) "
read answer
if [[ "$answer" == "y" ]]; then
# True condition
else