golang动态更新CCProxy账号对应的IP

环境:
Windows2008R2系统上安装CCProxy代理,安全起见只允许自己的IP可以使用代理。
由于自己使用的ADSL拨号,IP不固定,每次手动修改太麻烦。
所以使用Golang自动更新CCProxy配置。
大概过程:
1、自己这边使用一个DDNS,域名为 test.allgo.cc
2、使用golang每个1分钟解析一次test.allgo.cc
3、解析结果若同CCProxy配置中的不同,则更新配置
4、重新载入CCProxy配置

 

package main

/*
编译后台运行
go build -ldflags "-H windowsgui" -o ddns_ccproxy.exe edit_win_ini.go

goconfig库教程
https://github.com/Unknwon/go-rock-libraries-showcases/tree/master/lectures/01-goconfig
*/

import (
	"fmt"
	"github.com/Unknwon/goconfig"
	"log"
	"net"
	"os/exec"
	"time"
)

const (
	DDNS_STR      = "test.allgo.cc"
	INI_PATH      = "C:/CCProxy/AccInfo.ini"
	EXE_PATH      = "C:/CCProxy/CCProxy.exe"
	TIME_INTERVAL = 60
)

var (
	cfg_ip string
)

func main() {
	cfg, err := goconfig.LoadConfigFile(INI_PATH)
	if err != nil {
		log.Fatalf("无法加载配置文件:%s", err)
	}

	cfg_ip, err = cfg.GetValue("User001", "IPAddressLow")
	if err != nil {
		log.Fatalf("无法获取键值(%s):%s", "IPAddressLow", err)
	}
	log.Printf("%s > %s: %s", "User001", "IPAddressLow", cfg_ip)

	for {
		now_ip, err := get_cfg_ip()
		if err != nil {
			log.Printf("dns无法解析: %s", err)
		} else {
			if now_ip != cfg_ip {

				log.Printf("now_ip ->[%s] , cfg_ip->[%s]", now_ip, cfg_ip)

				//更新ini文件IP
				isInsert := cfg.SetValue("User001", "IPAddressLow", now_ip)
				log.Printf("设置键值 %s 为插入操作:%v", "IPAddressLow", isInsert)

				isInsert0 := cfg.SetValue("User001", "IPAddressHigh", now_ip)
				log.Printf("设置键值 %s 为插入操作:%v", "IPAddressHigh", isInsert0)

				//更新ini文件时间
				isInsert1 := cfg.SetValue("User001", "DisableDateTime", ntime())
				log.Printf("设置键值 %s 为插入操作:%v", "DisableDateTime", isInsert1)

				err := goconfig.SaveConfigFile(cfg, INI_PATH)
				if err != nil {
					log.Fatalf("无法保存配置文件:%s", err)
				}
				reload_ccproxy_cfg()
				err1 := cfg.Reload()
				if err1 != nil {
					log.Fatalf("重新载入ini配置失败:%s", err)
				}
				cfg_ip, err = cfg.GetValue("User001", "IPAddressLow")
				if err != nil {
					log.Fatalf("无法获取键值(%s):%s", "IPAddressLow", err)
				}
				log.Printf("%s > %s: %s", "User001", "IPAddressLow", cfg_ip)
			} else {
				log.Printf("DNS IP not change !")
			}
		}
		time.Sleep(time.Second * TIME_INTERVAL)
	}

}

//解析域名,返回字符串类型IP
func get_cfg_ip() (ip_str string, err error) {
	dns_ip, err := net.LookupIP(DDNS_STR)
	ip_str = iptostr(dns_ip[0])
	log.Printf("dns resolve : %s", ip_str)
	return ip_str, err
}

//获取当前时间
func ntime() string {
	tmpnow := time.Now()
	return fmt.Sprintf(tmpnow.Format("2006-01-02 15:04:05"))
}

//ip类型转字符串类型
func iptostr(tip net.IP) string {
	return fmt.Sprintf("%s", tip)
}

//重新加载CCProxy配置
func reload_ccproxy_cfg() {
	log.Println("Reload CCProxy Config...")
	argv := []string{"-update"}
	//fmt.Println(argv)
	_, err := exec.Command(EXE_PATH, argv...).Output()
	if err != nil {
		log.Printf("Reload CCProxy Config Error: %s", err)
	}
}

 

vbs系统后台持续检测一个进程是否存在

回答百度知道问题:
http://zhidao.baidu.com/question/713784585787480605

问题:
vbs,系统后台持续检测一个进程是否存在,如:qq.exe。如果存在,倒计时X秒将其关闭,如果不存在,继续后台检测。检测时间间隔可设置。

Const INTERVA = 5  '检测间隔
dim ps,ps_str
Set objShell = createobject("wscript.shell")
 
REM 解决CMD黑色闪运行
REM 参考<a href="http://demon.tw/programming/vbs-run-and-exec.html?replytocom=1928" target="_blank">http://demon.tw/programming/vbs-run-and-exec.html?replytocom=1928</a>
host = WScript.FullName
If LCase(Right(host, 11)) = "wscript.exe" Then
    objShell.run "cscript """ & WScript.ScriptFullName & chr(34), 0
    WScript.Quit
End If
REM -----------------------------------------------------------------------
 
do while true
    Set ps = objShell.Exec("tasklist")
    ps_str = ps.Stdout.ReadAll
    'msgbox ps_str
    if find_yn(ps_str) then
        objShell.Popup "5秒后将关闭 QQ !", 5, "Close QQ"
        Set ps = objShell.Exec("taskkill /F /IM QQ.exe /T")  '测试程序
    end if
    wscript.sleep 1000 * INTERVA  '检测间隔
loop
set ps = nothing
set objShell = nothing
 
 
Function find_yn(str_s)   '查找进程是否存在,不存在返回0
    Dim re,ms,m
    find_yn = 0
    set re = New RegExp
    re.Global = True
    re.MultiLine = True 
    're.Pattern = "^(QQa|QQb|QQ).exe"     '可以检测查看多个进程
    re.Pattern = "^QQ.exe"  '测试查找进程
    set ms = re.Execute(str_s)
    For Each m In ms
        'msgbox m
        find_yn = find_yn + 1
    Next
End Function

 

kickstart_示例

kickstart 示例

 

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled --http --ssh --port=123:udp
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
# Use network installation
url --url=http://192.168.211.50/cblr/links/centos7mini-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.211.50/cobbler/ks_mirror/centos7mini-x86_64

# Network information
# # Using "new" style networking config, by matching networking information to the physical interface's 
# MAC-address
# %include /tmp/pre_install_network_config

network  --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto
# --device=eth0 由于网卡的名字可能是eth0、em1、eno16777736等,--device制定的与目标机器网卡不一致时,会报错无法启动,顾不指定--device
# network --bootproto=static --ip=192.168.100.52 --netmask=255.255.255.0 --gateway=192.168.100.1 --nameserver=223.5.5.5,223.6.6.6 --onboot=on --ipv6=auto
# network --bootproto=dhcp --onboot=on --noipv6
# network --device team0 --activate --bootproto=static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 -teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}',p3p2'{\"prio\": 100}'" --teamconfig="{\"runner\": {\"name\": \"activebackup\"}}"

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$allgo$sjkKoGvJXV2AuBNFeHyxP.

# 加密密码生成
# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
# 其中 random-phrase-here 为干扰码

#add user
# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
user --name="centos" --password="$1$allgo$sjkKoGvJXV2AuBNFeHyxP." --iscrypted --uid=1000

# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
# timezone  Asia/Shanghai
timezone --ntpservers=110.75.186.247,cn.ntp.org.cn Asia/Shanghai
# --nontp Disable automatic starting of NTP service

# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
# autopart

# CentOS6 不支持xfs
# part / --asprimary --fstype="ext4" --size=20480
# part /boot --asprimary --fstype="ext4" --size=512
# part swap --asprimary --fstype="swap" --size=2048
# part /data --asprimary --fstype="ext4" --grow --size=1


# CentOS7 支持xfs
# part / --asprimary --fstype="xfs" --size=20480
# part /boot --asprimary --fstype="xfs" --size=512
# part swap --asprimary --fstype="swap" --size=2048
# part /data --asprimary --fstype="xfs" --grow --size=1

# CentOS7 使用LVM分区
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=10240  --name=root
logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data


# %pre部分脚本(系统安装前执行)系统在解析 ks.cfg 文件之后立即运行,而且必须以 %pre 命令开头。注意,你在 %pre 部分可以访问网络;然而,名称服务(name service)在此时还没有被配置,因此只有 IP 地址才能奏效。
%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &


curl "http://192.168.211.50/cblr/svc/op/trig/mode/pre/system/test" -o /dev/null
# Start pre_install_network_config generated code
# generic functions to be used later for discovering NICs
mac_exists() {
  [ -z "$1" ] && return 1

  if which ip 2>/dev/null >/dev/null; then
    ip -o link | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  elif which esxcfg-nics 2>/dev/null >/dev/null; then
    esxcfg-nics -l | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  else
    ifconfig -a | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  fi
}
get_ifname() {
  if which ip 2>/dev/null >/dev/null; then
    IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
  elif which esxcfg-nics 2>/dev/null >/dev/null; then
    IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
  else
    IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
    if [ -z $IFNAME ]; then
      IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
    fi
  fi
}

# Start of code to match cobbler system interfaces to physical interfaces by their mac addresses
#  Start eno16777736
# Configuring eno16777736 (00:0C:29:48:30:63)
if mac_exists 00:0C:29:48:30:63
then
  get_ifname 00:0C:29:48:30:63
  echo "network --device=$IFNAME --bootproto=static --ip=192.168.211.11 --netmask=255.255.255.0 --gateway=192.168.211.1 --hostname=test.mydomain.com" >> /tmp/pre_install_network_config
fi
# End pre_install_network_config generated code

# Enable installation monitoring

%end

# %packages 指令也支持下面的选项:
# --nobase,不要安装@Base 组.如果想创建一个很小的系统,可以使用这个选项.
# --resolvedeps,选项已经被取消了.目前依赖关系可以自动地被解析.
# --ignoredeps,选项已经被取消了.目前依赖关系可以自动地被解析.
# --ignoremissing,忽略缺少的软件包或软件包组,而不是暂停安装来向用户询问是中止还是继续安装.
# 例如:%packages --ignoremissing
%packages --ignoremissing --nobase
@Core
vim
wget
%end

# %post部分脚本系统安装后执行, DHCP配置网络没有配置dns服务器
%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1

%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
# curl "http://192.168.211.50/cblr/svc/op/yum/system/test" --output /etc/yum.repos.d/cobbler-config.repo

# End yum configuration



# Start post_install_network_config generated code

# create a working directory for interface scripts
mkdir /etc/sysconfig/network-scripts/cobbler
cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/cobbler/

# set the gateway in the network configuration file
grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "GATEWAY=192.168.211.1" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network

# set the hostname in the network configuration file
grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "HOSTNAME=test.mydomain.com" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network

# Also set the hostname now, some applications require it
# (e.g.: if we're connecting to Puppet before a reboot).
/bin/hostname test.mydomain.com

# Start configuration for eno16777736
echo "DEVICE=eno16777736" > /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "HWADDR=00:0C:29:48:30:63" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
IFNAME=$(ip -o link | grep -i '00:0C:29:48:30:63' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
if [ -f "/etc/modprobe.conf" ] && [ $IFNAME ]; then
    grep $IFNAME /etc/modprobe.conf | sed "s/$IFNAME/eno16777736/" >> /etc/modprobe.conf.cobbler
    grep -v $IFNAME /etc/modprobe.conf >> /etc/modprobe.conf.new
    rm -f /etc/modprobe.conf
    mv /etc/modprobe.conf.new /etc/modprobe.conf
fi
echo "TYPE=Ethernet" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "IPADDR=192.168.211.11" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
# End configuration for eno16777736

sed -i 's/ONBOOT=yes/ONBOOT=no/g' /etc/sysconfig/network-scripts/ifcfg-eth*

rm -f /etc/sysconfig/network-scripts/ifcfg-eno16777736
mv /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/
rm -r /etc/sysconfig/network-scripts/cobbler
if [ -f "/etc/modprobe.conf" ]; then
cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
rm -f /etc/modprobe.conf.cobbler
fi
# End post_install_network_config generated code




# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)

# Start koan environment setup
echo "export COBBLER_SERVER=192.168.211.50" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.211.50" > /etc/profile.d/cobbler.csh
# End koan environment setup

# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration

# Begin cobbler registration
# skipping for system-based installation
# End cobbler registration

# Enable post-install boot notification

# Start final steps

curl "http://192.168.211.50/cblr/svc/op/ks/system/test" -o /root/cobbler.ks
curl "http://192.168.211.50/cblr/svc/op/trig/mode/post/system/test" -o /dev/null
# End final steps
%end

 

 

 

CentOS7x64下安装Cobbler

测试中发现,无法导入32位系统镜像,使用32位的CentOS安装Cobbler也不行,目前未解决。

 

# 安装环境
# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

# rpm -qa cobbler
cobbler-2.6.10-1.el7.noarch

####################################################################################
#
#安装过程
#
####################################################################################
# 增加repo源
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
# 或
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 安装Cobbler及相关软件
yum -y install httpd xinetd tftp-server dnsmasq rsync syslinux
yum -y install cobbler fence-agents pykickstart

# 关闭selinux
# vi /etc/selinux/config 
SELINUX=disabled

# 获取selinux状态
# getenforce

# 关闭iptables
systemctl stop firewalld
systemctl disable firewalld 

# 生成系统安装后,root的密码 (默认密码为 cobbler)
# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
# 其中 random-phrase-here 为干扰码

# openssl passwd -1 -salt 'allgo' 'allgo.cc'                                 
$1$allgo$sjkKoGvJXV2AuBNFeHyxP.

# 修改Cobbler配置/etc/cobbler/settings
manage_dhcp:1
manage_dns:1
manage_tftpd:1
restart_dhcp:1
restart_dns:1
next_server:<服务器的 IP 地址>
server:<服务器的 IP 地址>
default_password_crypted: "$1$allgo$sjkKoGvJXV2AuBNFeHyxP."

# 修改 modules,使用dnsmasq作为DHCP、DNS服务器
# vi /etc/cobbler/modules.conf
[dns]
module = manage_dnsmasq

[dhcp]
module = manage_dnsmasq

[tftpd]
module = manage_in_tftpd

# 修改dnsmasq配置文件 /etc/dnsmasq.conf 
# vi /etc/dnsmasq.conf 

# Cobbler generated configuration file for dnsmasq
# $date
#

# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts

dhcp-range=192.168.211.10,192.168.211.29,255.255.255.0
dhcp-ignore=tag:!known
dhcp-option=3,$next_server
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,$elilo

$insert_cobbler_system_definitions

# TFTP配置
# cat /etc/xinetd.d/tftp 
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

systemctl start xinetd.service
systemctl status xinetd.service
systemctl enable xinetd.service

systemctl start tftp.socket
systemctl status tftp.socket
systemctl enable tftp.socket

systemctl start tftp.service
systemctl status tftp.service
systemctl enable tftp.service

# 配置httpd
cd /etc/httpd/conf.d/
#移除并备份conf文件,目的不显示测试页面
mv autoindex.conf autoindex.conf.bak
mv userdir.conf userdir.conf.bak
mv welcome.conf welcome.conf.bak


# 启动httpd、Cobbler
systemctl start httpd.service
systemctl enable httpd.service
systemctl status httpd.service

systemctl start cobblerd.service
systemctl enable cobblerd.service
systemctl status cobblerd.service

# Cobbler检查,会检测到一些错误,根据提示解决
cobbler check

# Cobbler配置应用
cobbler sync

# 查看相关应用是否启动
ss -naltu


# 准备安装文件
# 导入iso文件
mount -t iso9660 -o loop,ro /os/CentOS-7-x86_64-Minimal-1503-01.iso /mnt
cobbler import --name=centos7mini --path=/mnt --arch=x86_64
# cobbler import --arch=x86_64 --path=/mnt --name=centos7mini2

# 查看导入结果
cobbler distro list
cobbler distro report
cobbler profile report

# 添加kickstart配置文件
# 从现有sample_end 修改得到
# cp /var/lib/cobbler/kickstarts/sample_end.ks /var/lib/cobbler/kickstarts/jxl_data.ks
# vi /var/lib/cobbler/kickstarts/jxl_data.ks
timezone Asia/Shanghai --isUtc
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8

# 添加账号
# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
user --name="centos" --iscrypted="$1$juxinli$PEn5Sl/DCkrLOGeSmVrFP1" --uid=1000


# Allow anaconda to partition the system as needed
# autopart

# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --asprimary --fstype="xfs" --size=204800
part /boot --asprimary --fstype="xfs" --size=1024
part swap --asprimary --fstype="swap" --size=4096
# kvm
part /vm --asprimary --fstype="xfs" --grow --size=1
# data
part /data --asprimary --fstype="xfs" --grow --size=1

#LVM-data
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=4096
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data


#LVM-kvm
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=4096
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
logvol  /vm  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=vm







# cobbler profile add --name=Fedora17-xfce --ksmeta='desktop_pkg_group=@xfce-desktop' --kickstart=/var/lib/cobbler/kickstarts/example.ks --parent=centos7mini2-x86_64
# cobbler profile add --name=centos-data --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks --parent=centos7mini2-x86_64

# 修改kickstart文件
cobbler profile edit --name=centos7mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks

# 验证kickstart文件内容
cobbler profile getks --name=centos7mini-x86_64

# 配置需要安装的机器 
# 针对MAC为00:0C:29:48:30:63的机器安装
cobbler system add --name=test --profile=centos7mini-x86_64 --interface=eno16777736 --mac=00:0C:29:48:30:63 --ip-address=192.168.211.11 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com --gateway=192.168.211.1 --hostname=test.mydomain.com

cobbler system report


#######
# 让配置生效
cobbler sync

#######注意################
# 检查 dnsmasq dhcp-range是否正确,因为cobbler sync 会修改
grep "range" /etc/dnsmasq.conf
dhcp-range=192.168.211.10,192.168.211.20

# 修改/etc/dnsmasq.conf 后需要重启dnsmasq
systemctl restart dnsmasq.service



##############################
# 安装Cobbler Web 界面

yum -y install cobbler-web
# 修改授权
# /etc/cobbler/modules.conf 
[authentication]
module = authn_pam

[authorization]
module = authz_ownership

# 添加Cobbler_web 账号
# useradd web && passwd web

# 将 账号 添加到Cobbler_web admins组
# cat /etc/cobbler/users.conf 
[admins]
admin = ""
cobbler = ""
web = ""

# 重启服务
service cobblerd restart
service httpd restart

# 登录WEB(注意使用https)
https://192.168.211.131/cobbler_web/


# Cobbler 子命令介绍
cobbler check         #检查cobbler配置
cobbler sync          #步配置到dhcp pxe和数据目录
cobbler list          #列出所有的cobbler元素
cobbler import        #导入安装的系统光盘镜像
cobbler report        #列出各元素的详细信息
cobbler distro        #查看导入的发行版系统信息
cobbler profile       #查看配置信息
cobbler system        #查看添加的系统信息
cobbler reposync      #同步yum仓库到本地

cobbler repo add --name=CentOS-7-x86_64 --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/
cobbler reposync


# 参考文档
# Cobbler官网
http://cobbler.github.io/manuals/quickstart/
http://cobbler.github.io/manuals/2.6.0/
# dnsmasq设置
http://debugo.com/dnsmasq/
# 使用 Cobbler 自动化和管理系统安装
http://www.ibm.com/developerworks/cn/linux/l-cobbler/
# Cobbler自动化工具同时批量部署CentOS7及CentOS6.5
http://www.tuicool.com/articles/YZN3qi
#kickstart配置文件详解
http://blog.chinaunix.net/uid-17240700-id-2813881.html

 

wget 下载 java或jdk

Oracle官网上下载jdk,需要点击accept licence的才能下载,使用下面的命令,直接可以下载。

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

下载完毕后最好验证一下md5

# md5sum jdk-7u79-linux-x64.rpm jdk-7u79-linux-x64.rpm 
8486da4cdc4123f5c4f080d279f07712  jdk-7u79-linux-x64.rpm

下载页面:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

https://www.oracle.com/webfolder/s/digest/7u79checksum.html

 

参考:http://www.oschina.net/code/snippet_875267_44726

Canon照片风格设置

Set Canon Photo Style

 

Canon官方照片风格 (pf2格式文件)
http://www.canon.com.cn/front/product/PStyle/

清晰等:
http://www.canon.com.cn/front/product/PStyle/file/clear.html

收集的  228种常用佳能DPP风格.zip
链接:http://pan.baidu.com/s/1mgGhDZM 密码:0ibo

几种照片风格对比:

继续阅读

Windows批处理让主板发出蜂鸣(报警)

先解释一下,为什么需要这个:
今天有一台服务器Nagios一直在报警,之前的维护人员已经离职,找不到这台服务器在哪个位置了,但是可以远程登录。所以想到,可以让这台服务器的主板报警(或蜂鸣),通过声音去找到它。

通过它我们很容易就找到了这台服务器 ^^

cmd命令:
for /l %i in (1,1,100) do ^G

^G 是 Ctrl+G ,不是 ^ 和 G

注意:Win7不适用,Win7的是通过声卡发出。

参考文档:
http://bbs.anjian.com/thread-382245-1-1.html

CentOS下安装Jira

  安装环境:

# cat /etc/redhat-release 
CentOS release 6.6 (Final)

# uname -a
Linux Jira-it 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

# java -version
java version "1.6.0_36"
OpenJDK Runtime Environment (IcedTea6 1.13.8) (rhel-1.13.8.1.el6_7-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
 
# javac -version
javac 1.6.0_36

# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Jira检查安装环境:

# /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/version.sh 
                .....
          .... .NMMMD.  ...
        .8MMM.  $MMN,..~MMMO.
        .?MMM.         .MMM?.

     OMMMMZ.           .,NMMMN~
     .IMMMMMM. .NMMMN. .MMMMMN,
       ,MMMMMM$..3MD..ZMMMMMM.
        =NMMMMMM,. .,MMMMMMD.
         .MMMMMMMM8MMMMMMM,
           .ONMMMMMMMMMMZ.
             ,NMMMMMMM8.
            .:,.$MMMMMMM
          .IMMMM..NMMMMMD.
         .8MMMMM:  :NMMMMN.
         .MMMMMM.   .MMMMM~.
         .MMMMMN    .MMMMM?.

      Atlassian JIRA
      Version : 6.3.6
                  
Detecting JVM PermGen support...
PermGen switch is supported. Setting to 384m

If you encounter issues starting or stopping JIRA, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide


Server startup logs are located in /usr/share/jira/atlassian-jira-6.3.6-standalone/logs/catalina.out
Using CATALINA_BASE:   /usr/share/jira/atlassian-jira-6.3.6-standalone
Using CATALINA_HOME:   /usr/share/jira/atlassian-jira-6.3.6-standalone
Using CATALINA_TMPDIR: /usr/share/jira/atlassian-jira-6.3.6-standalone/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/bootstrap.jar:/usr/share/jira/atlassian-jira-6.3.6-standalone/bin/tomcat-juli.jar
Using CATALINA_PID:    /usr/share/jira/atlassian-jira-6.3.6-standalone/work/catalina.pid
Server version: Apache Tomcat/7.0.55
Server built:   Jul 18 2014 05:34:04
Server number:  7.0.55.0
OS Name:        Linux
OS Version:     2.6.32-504.el6.x86_64
Architecture:   amd64
JVM Version:    1.6.0_36-b36
JVM Vendor:     Sun Microsystems Inc.

安装过程: 继续阅读