代码拉取完成,页面将自动刷新
同步操作将从 awakenjoys/Auto_Install_console 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding:utf8 -*-
from core import *
#----------------------------------------------------------------------------------------
#安装基础软件
def install_basic(server, port, username, password, ostype):
if ostype == "centos":
cmd_install = "yum -y install unzip ntp rsync lrzsz libaio1 python-setuptools; easy_install supervisord"
elif ostype == "ubuntu" :
cmd_install = "apt-get -y install unzip ntp libaio1 rsync lrzsz snmpd python-setuptools python-pip; pip install supervisord "
else:
cmd_install = "uptime"
cmds = []
cmds.append(cmd_install)
ret = execute(server, port, username, password, cmds)
return ret
#----------------------------------------------------------------------------------------
#设置主机名
def set_hostname(server, port, username, password, hostname):
genconfigfile("/tmp/hostname", "basic/hostname.tpl", {'hostname' : hostname})
return upload(server, port, username, password, "/tmp/hostname", "/etc/hostname")
#----------------------------------------------------------------------------------------
#配置ntp
def set_ntpserver(server, port, username, password, ntpserver):
genconfigfile("/tmp/ntp.conf", "basic/ntp.tpl", {'ntpserver' : ntpserver})
return upload(server, port, username, password, "/tmp/ntp.conf", "/etc/ntp.conf")
#----------------------------------------------------------------------------------------
#设置history的记录格式及记录条数
def set_history(server, port, username, password):
genconfigfile("/tmp/profile", "basic/profile.tpl")
return upload(server, port, username, password, "/tmp/profile", "/etc/profile")
#genconfigfile("/root/.bashrc", "basic/.bashrc.tpl")
#upload(server, port, username, password, "/tmp/.bashrc", "/root/.bashrc")
#----------------------------------------------------------------------------------------
#设置DNS服务器
def set_nameserver(server, port, username, password):
genconfigfile("/tmp/resolv.conf", "basic/resolv.tpl")
return upload(server, port, username, password, "/tmp/resolv.conf", "/etc/resolv.conf")
#----------------------------------------------------------------------------------------
#设置时区
def set_timezone(server, port, username, password):
genconfigfile("/tmp/localtime", "basic/Shanghai")
return upload(server, port, username, password, "/tmp/localtime", "/etc/localtime")
#----------------------------------------------------------------------------------------
#关闭selinux
def set_selinux(server, port, username, password, ostype):
if ostype == "centos":
genconfigfile("/tmp/selinux_config", "basic/selinux.tpl")
return upload(server, port, username, password, "/tmp/selinux_config", "/etc/selinux/config")
else:
return u'Other os type'
#----------------------------------------------------------------------------------------
#配置sysctl
def set_sysctl(server, port, username, password):
genconfigfile("/tmp/sysctl.conf", "basic/sysctl.tpl")
return upload(server, port, username, password, "/tmp/sysctl.conf", "/etc/sysctl.conf")
#----------------------------------------------------------------------------------------
#设置limlits
def set_limlits(server, port, username, password):
genconfigfile("/tmp/security_limits.conf", "basic/limits.tpl")
return upload(server, port, username, password, "/tmp/security_limits.conf", "/etc/security/limits.conf")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。