zhuangdebiao 发布的文章

var system = {};
var p = navigator.platform;
var u = navigator.userAgent;

system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if (system.win || system.mac || system.xll) {
    if (u.indexOf('Windows Phone') > -1) {

    }else {
        window.location.href = "1";
    }
} 

修改platform失败

Object.defineProperty(navigator,'platform',{get:function(){return 'Android';}});


wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz

tar xvf gogs_0.11.91_linux_amd64.tar.gz

adduser git  //创建用户 git
passwd git  //设置密码

# 创建用户组
groupadd git

# 将用户git加入用户组git
usermod -G git git

mv /gogs /home/git/gogs

mkdir /home/git/repo


cd /home/git/gogs

mkdir -P custom/conf

cd custom/conf

vi app.ini

内容是:

RUN_USER = git
RUN_MODE = prod
APP_NAME = 庄德彪

[server]
ROOT_URL                         = http://git.zdb.im/
DOMAIN                           = git.zdb.im
PROTOCOL                         = http
# 证书文件
; #CERT_FILE = /usr/local/nginx/conf/ssl/gogs.zdb.im/fullchain.cer
; # KEY_FILE = /usr/local/nginx/conf/ssl/gogs.zdb.im/gogs.zdb.im.key
HTTP_ADDR                        = 127.0.0.1
HTTP_PORT                        = 3000
OFFLINE_MODE                     = true
DISABLE_ROUTER_LOG               = true
ENABLE_GZIP                      = false
; Whether to disable SSH access to the application entirely.
DISABLE_SSH                      = false
; The domain name to be exposed in SSH clone URL.
SSH_DOMAIN                       = git.zdb.im
; The port number to be exposed in SSH clone URL.
SSH_PORT                         = 2222
; The path of SSH root directory, default is "$HOME/.ssh".
SSH_ROOT_PATH                    = /home/git/.ssh
; The path to ssh-keygen, default is "ssh-keygen" and let shell find out which one to call.
SSH_KEYGEN_PATH                  = ssh-keygen
; Whether to check minimum public key size with corresponding type.
MINIMUM_KEY_SIZE_CHECK           = false
; Whether to rewrite "~/.ssh/authorized_keys" file at start, ignored when use builtin SSH server.
REWRITE_AUTHORIZED_KEYS_AT_START = false
; Whether to start a builtin SSH server.
START_SSH_SERVER                 = true
; The network interface for builtin SSH server to listen on.
SSH_LISTEN_HOST                  = 0.0.0.0
; The port number for builtin SSH server to listen on.
SSH_LISTEN_PORT                  = %(SSH_PORT)s
; The list of accepted ciphers for connections to builtin SSH server.
SSH_SERVER_CIPHERS               = aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, arcfour256, arcfour128

[repository]
ROOT                        = /home/git/repo
SCRIPT_TYPE                 = bash
FORCE_PRIVATE               = false
MAX_CREATION_LIMIT          = -1
PREFERRED_LICENSES          = ISC license
DISABLE_HTTP_GIT            = false
ENABLE_LOCAL_PATH_MIGRATION = false
ENABLE_RAW_FILE_RENDER_MODE = false

[database]
; The database backend, either "postgres", "mysql" "sqlite3" or "mssql".
; ; You can connect to TiDB with MySQL protocol.
TYPE           = mysql
HOST           = 127.0.0.1:3306
NAME           = gogs
USER           = root
PASSWORD       = 
; For "postgres" only, either "disable", "require" or "verify-full".
; ; SSL_MODE = disable
; ; For "sqlite3" only, make sure to use absolute path.
; ; PATH = data/gogs.db
; ; The maximum open connections of the pool.
MAX_OPEN_CONNS = 30
; The maximum idle connections of the pool.
MAX_IDLE_CONNS = 30
DB_TYPE        = mysql
PASSWD         = 
SSL_MODE       = disable
PATH           = data/gogs.db

[security]
SECRET_KEY          = 1234567899abcef
LOGIN_REMEMBER_DAYS = 7
INSTALL_LOCK        = true

[http]
; The value for "Access-Control-Allow-Origin" header, default is not to present.
ACCESS_CONTROL_ALLOW_ORIGIN = *

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = false
DISABLE_REGISTRATION   = false
ENABLE_CAPTCHA         = true
REQUIRE_SIGNIN_VIEW    = false

[picture]
DISABLE_GRAVATAR        = true
ENABLE_FEDERATED_AVATAR = false

[user]
; Whether to enable email notifications for users.
ENABLE_EMAIL_NOTIFICATION = false

[session]
; The session provider, either "memory", "file", or "redis".
PROVIDER = memory
; The configuration for respective provider:
; - memory: does not need any config yet
; - file: session file path, e.g. `data/sessions`
; - redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
PROVIDER_CONFIG = data/sessions
; The cookie name to store the session identifier.
COOKIE_NAME = git
; Whether to set cookie in HTTPS only.
COOKIE_SECURE = false
; The GC interval in seconds for session data.
GC_INTERVAL = 3600
; The maximum life time in seconds for a session.
MAX_LIFE_TIME = 86400
; The cookie name for CSRF token.
CSRF_COOKIE_NAME = _csrf

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /home/git/gogs/log

[other]
SHOW_FOOTER_BRANDING = false
; Show time of template execution in the footer
SHOW_FOOTER_TEMPLATE_LOAD_TIME = true



[attachment]
; Whether to enabled upload attachments in general.
ENABLED = true
; The path to store attachments on the file system.
PATH = data/attachments
; File types that are allowed to be uploaded, e.g. "image/jpeg|image/png". Leave empty to allow any file type.
ALLOWED_TYPES = 
; The maximum size of each file in MB.
MAX_SIZE = 32
; The maximum number of files per upload.
MAX_FILES = 9999

[release.attachment]
; Whether to enabled upload attachments for releases.
ENABLED = true
; File types that are allowed to be uploaded, e.g. "image/jpeg|image/png". Leave empty to allow any file type.
ALLOWED_TYPES = */*
; The maximum size of each file in MB.
MAX_SIZE = 32
; The maximum number of files per upload.
MAX_FILES = 10

[cache]
; The cache adapter, either "memory", "redis", or "memcache".
ADAPTER = memory
; For "memory" only, GC interval in seconds.
INTERVAL = 60
; For "redis" and "memcache", connection host address:
; - redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
; - memcache: `127.0.0.1:11211`
HOST =

chown -R git:git /home/git/repo
chown -R git:git /home/git/gogs

vi /lib/systemd/system/gogs.service

[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mysqld.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git

[Install]
WantedBy=multi-user.target

启用服务:

systemctl enable gogs.service

启动服务:

systemctl start gogs

查看状态:

systemctl status gogs

nginx config

server {
    listen 80;
    server_name git.zdb.im;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}


server {
    listen 443 ssl;
    server_name git.zdb.im;
    ssl_certificate 证书;
    ssl_certificate_key 证书key;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}

SHOW VARIABLES LIKE 'event_scheduler';

SET GLOBAL event_scheduler=on;

CREATE EVENT prod.bugfix_insert_failure
ON SCHEDULE
EVERY 5 SECOND STARTS NOW() DO delete from ol_device where status=0 limit 1;