Skip to content

Instantly share code, notes, and snippets.

View perfectfoolish's full-sized avatar
🎯
Focusing

Fulei Li perfectfoolish

🎯
Focusing
View GitHub Profile
@perfectfoolish
perfectfoolish / check_root.sh
Created April 16, 2014 07:07
How to: Check the bash shell script is being run by root or not
http://www.cyberciti.biz/tips/shell-root-user-check-script.html
Sometime it is necessary to find out if a shell script is being run as root user or not.
When user account created a user ID is assigned to each user. BASH shell stores the user ID in $UID variable. Your effective user ID is stored in $EUID variable. You can
Old way...
You can easily add a simple check at the start of a script:
require 'socket'
require 'nokogiri'
host = 'www.so.com'
port = 80
path = "http://www.so.com/s?psid=aa1636dc9ced822ddb741bd94af183fc&q=%E8%89%BA%E9%BE%99&pq=%E8%89%BA%E9%BE%99&src=srp&fr=360sou_newhome"
request = "GET #{path} HTTP/1.0\r\n\r\n"
socket = TCPSocket.open(host, port)
socket.print(request)
syntax on
" space
set expandtab
set tabstop=2
set shiftwidth=2
" EOL whitespace
set list
set listchars=trail:+
[alias]
unstage = reset HEAD
throw = reset --hard HEAD
throwh = reset --hard HEAD^
st = status
ci = commit -v
co = checkout
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
[color]
install: "--no-rdoc --no-ri"
update: "--no-rdoc --no-ri"
The ALLUSERS=1 switch worked. How do you know these things? :-)
I have no experience with installers. I searched Google, but I think I didn't even know what I needed to be searching for. Thanks for the help.
Don Jones · July 10, 2014 at 9:33 am #16975
Don Jones
Keymaster
@perfectfoolish
perfectfoolish / zabbix_server.spec
Created March 19, 2015 05:59
# yum install -y gcc make mysql-devel net-snmp-devel curl-devel
%define path /usr/local/zabbix
%define real_name zabbix
Name:zabbix_server-ThoughtWorks
Version:2.2.3
Release:1.centos
Summary:zabbix_server for ThoughtWorks
Group:System Environment/Daemons
License:GPL
@perfectfoolish
perfectfoolish / rpmbuild_dir.sh
Last active August 29, 2015 14:17
Build the source code to RPM, # rpm -ivh zabbix .centos.src.rpm, # rpmbuild -ba rpmbuild/SPECS/zabbix_server.spec
#! /usr/bin/env bash
yum install -y rpm-build
yum install -y tree
mkdir -p rpmbuild/BUILD rpmbuild/BUILDROOT rpmbuild/RPMS rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/SRPMS
echo "######"
tree rpmbuild
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
PUBLIC_IP="$(ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}')"