Skip to content

Instantly share code, notes, and snippets.

View rluisr's full-sized avatar
🤒
Out sick

Hasegawa Takuya rluisr

🤒
Out sick
View GitHub Profile
@rluisr
rluisr / p-s.sh
Last active August 4, 2017 12:32
Wait for a Host to be up and Slack notification
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Need arg for host."
echo "ex) p-s 192.168.20.100"
exit 1
elif [ $# -eq 1 ]; then
HOST=$1
fi
@rluisr
rluisr / get_temperature.sh
Last active August 9, 2017 02:18
Get temparature from Vyatta | EdgeOS hardware using shellscript.
#!/bin/vbash
args=$1
# Setup for using vyatta command
# =================================
shopt -s expand_aliases
. /etc/bash_completion.d/vyatta-op
result=`show hardware temperature`
@rluisr
rluisr / reboot-all-lxc.sh
Created May 2, 2017 16:34
[Bash one liner] Reboot all LXC Container
for i in `(lxc-ls)`; do lxc-stop -n $i -r; done
@rluisr
rluisr / stop.sh
Created February 11, 2017 10:10
for
#!/bin/bash
i=$1
shift
(sleep $i; kill $$) & exec "$@"
@rluisr
rluisr / startup-api.service
Created January 25, 2017 13:47
Add service as systemd
[Unit]
Description=Run API program as node user on boot
[Service]
Type=simple
RemainAfterExit=yes
User=node
ExecStart=/usr/bin/forever start /home/node/Web-API/app.js
ExecStop=/usr/bin/forever stop /home/node/Web-API/app.js
ExecReload=/usr/bin/forever restart /home/node/Web-API/app.js
@rluisr
rluisr / check_cache.php
Created January 15, 2017 08:21
check wordpress WP_CACHE
<?php
function check_cache()
{
$path = preg_replace("/wp-content/", " ", WP_CONTENT_DIR);
$path = trim($path);
$wp_config = file_get_contents("${path}wp-config.php");
if (preg_match("/^define\('WP_CACHE',\s*true\);/mi", $wp_config) === 1) {
file_put_contents(WP_CONTENT_DIR . '/block-wpscan/cache_status', "1", LOCK_EX);
@rluisr
rluisr / shutdown.sh
Last active October 7, 2016 05:07
Shutdown All VMs. Using `virsh`.
#!/bin/bash -e
virsh list --all | egrep '実行中|running' | awk '{print $2}' | xargs -t -I {} virsh shutdown {}
@rluisr
rluisr / app.js
Created July 29, 2016 16:57
【Node.js】 Check tracking status. This code supports 349 couriers. Notify with Twitter.
/*
* Notify tracking status with Twitter on Node.js.
*
* Usage
* -------------------
* node app.js "<tracking number>" "<your twitter username>"
*
* This code scraping 'track.aftership.com'
*/
@rluisr
rluisr / rc
Last active June 29, 2016 02:50
Notify you through Slack when SSH connection is established.
#!/bin/bash
url="<web hook url>"
readonly USER=`whoami`
readonly HOST=`hostname`
ip=`lastlog | grep -w "${USER}" | awk '{print $3}'`
day=`lastlog | grep -w "${USER}" | awk '{print $4}'`
month=`lastlog | grep -w "${USER}" | awk '{print $5}'`
@rluisr
rluisr / smart.php
Created May 30, 2016 07:56
S.M.A.R.T check for Zabbix
<?php
/**
SMARTで異常があるかどうか調べる。
( This script checks S.M.A.R.T for Zabbix. )
=== Setting ===
[zabbix_agentd.conf]
+ UserParameter=hdd.smart[*],/usr/bin/php /path/to/smart.php $1 $2 $3
+ AllowRoot=1