pull/109/head
Mr Chen 6 years ago
parent 09732ab3ec
commit 09412bc532
  1. 18
      plugins/gogs/conf/app.ini
  2. 31
      plugins/gogs/index.py
  3. 2
      plugins/gogs/init.d/gogs.tpl

@ -1,26 +1,26 @@
APP_NAME = Gogs
RUN_USER = root
RUN_USER = {$RUN_USER}
RUN_MODE = prod
[database]
DB_TYPE = sqlite3
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gogs
USER = root
PASSWD =
USER = gogs
PASSWD = gogs
SSL_MODE = disable
PATH = data/gogs.db
[repository]
ROOT = /www/gogs-repositories
ROOT = {$ROOT_PATH}/gogs-repositories
[server]
DOMAIN = 154.48.251.71
DOMAIN = 127.0.0.1
HTTP_PORT = 3000
ROOT_URL = http://154.48.251.71:3000/
ROOT_URL = http://127.0.0.1:3000/
DISABLE_SSH = false
SSH_PORT = 222
START_SSH_SERVER = true
START_SSH_SERVER = false
OFFLINE_MODE = false
[mailer]
@ -43,7 +43,7 @@ PROVIDER = file
[log]
MODE = console, file
LEVEL = Info
ROOT_PATH = /www/server/gogs/log
ROOT_PATH = {$SERVER_PATH}/gogs/log
[security]
INSTALL_LOCK = true

@ -67,6 +67,11 @@ def getConf():
return path
def getConfTpl():
path = getPluginDir() + "/conf/app.ini"
return path
def status():
data = public.execShell(
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
@ -75,6 +80,21 @@ def status():
return 'start'
def contentReplace(content):
user = public.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
service_path = public.getServerDir()
content = content.replace('{$ROOT_PATH}', public.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$RUN_USER}', user)
if public.isAppleSystem():
content = content.replace('{$HOME_DIR}', '/Users/' + user)
else:
content = content.replace('{$HOME_DIR}', '/root')
return content
def initDreplace():
file_tpl = getInitdConfTpl()
@ -85,11 +105,20 @@ def initDreplace():
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(file_bin):
public.execShell('mkdir -p ' + getServerDir() + '/custom/conf')
content = public.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
content = contentReplace(content)
public.writeFile(file_bin, content)
public.execShell('chmod +x ' + file_bin)
conf_bin = getConf()
if not os.path.exists(file_bin):
conf_tpl = getConfTpl()
content = public.readFile(conf_tpl)
content = contentReplace(content)
public.writeFile(conf_bin, content)
log_path = getServerDir() + '/log'
if not os.path.exists(log_path):
os.mkdir(log_path)

@ -26,7 +26,7 @@ if [ -f /etc/init.d/functions ];then
fi
# Default values
HOME=/root
HOME={$HOME_DIR}
NAME=gogs
GOGS_HOME={$SERVER_PATH}/gogs
GOGS_PATH=${GOGS_HOME}/$NAME

Loading…
Cancel
Save