Commit 8efb4bb6 authored by jose's avatar jose

Update public.py

parent 141510f1
......@@ -734,10 +734,10 @@ def checkWebConfig():
if os.path.exists(f3): os.remove(f3)
if get_webserver() == 'nginx':
result = ExecShell("ulimit -n 8192 && /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf");
result = ExecShell("ulimit -n 8192 ; /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf");
searchStr = 'successful'
else:
result = ExecShell("ulimit -n 8192 && /www/server/apache/bin/apachectl -t");
result = ExecShell("ulimit -n 8192 ; /www/server/apache/bin/apachectl -t");
searchStr = 'Syntax OK'
if result[1].find(searchStr) == -1:
......@@ -1227,3 +1227,29 @@ def mod_reload(mode):
imp.reload(module)
return True
except: return False
#设置权限
def set_mode(filename,mode):
if not os.path.exists(filename): return False
mode = int(str(mode),8)
os.chmod(filename,mode)
return True
#设置用户组
def set_own(filename,user,group=None):
if not os.path.exists(filename): return False
from pwd import getpwnam
try:
user_info = getpwnam(user)
user = user_info.pw_uid
if group:
user_info = getpwnam(group)
group = user_info.pw_gid
except:
#如果指定用户或组不存在,则使用www
user_info = getpwnam('www')
user = user_info.pw_uid
group = user_info.pw_gid
os.chown(filename,user,group)
return True
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment