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
#!/usr/bin/env python | |
# vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4 smarttab textwidth=78 | |
from __future__ import print_function | |
import os | |
import sys | |
from u115 import API, File, Directory | |
ARGV = sys.argv | |
GLOB_ALL = False |
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
wget -qO - https://gist.githubusercontent.com/shichao-an/c55ba272567b44f50fb6/raw/2edec4ad9b090d78c9690c245dfe0493a7d9f8aa/wb.sh | bash |
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 | |
# Set hostname on Ubuntu 12.04 and 14.04 | |
usage='Usage: set-hostname.sh HOSTNAME' | |
[ $# -ne 1 ] && { echo "$usage" >&2; exit 1; } | |
echo 'Updating hostname...' | |
if which hostnamectl > /dev/null | |
then | |
# Ubuntu 14.04 that ships with hostnamectl |
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
#!/usr/bin/env python | |
# Get CPU (core number) and memory by instance_type | |
# usage: python instance.py (INSANCE_TYPE|VCPU MEMORY) | |
import json | |
import sys | |
import urllib2 | |
JSON_URL = 'https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json' |
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
#!/usr/bin/env python | |
# vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4 smarttab textwidth=78 | |
# | |
# Upload a torrent file and create a BitTorrent task | |
# Usage: python 115wangpan-up.py TORRENT_FILE | |
from __future__ import print_function | |
import sys | |
from u115 import API |
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 | |
# This script checks nginx error log for "upstream timed out" events | |
# Update $last_num variable to the latest error number after you fixed the issue | |
last_num=75305 | |
log_file=/var/log/nginx/error.log | |
[ -f "$log_file" ] || { echo "WARNING - error log does not exist: $log_file"; exit 1; } | |
current_num=$(grep 'upstream timed out' "$log_file" | tail -1 | awk ' { print $5 }' | tr -d '*') | |
# If $current_num is not empty string and larger than $last_num, then we get an error | |
[ -n "$current_num" ] && [ "$current_num" -gt $last_num ] && \ |
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
apt-get install nagios-nrpe-server nagios-plugins |
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
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.key |
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/sh | |
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm | |
yum install -y yum-plugin-replace | |
yum replace -y php-common --replace-with=php55w-common |
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 | |
# Run as root | |
set -e | |
apt-get update | |
apt-get install -y build-essential | |
apt-get install -y libncurses5-dev | |
useradd mysql |