OpenWRT git服务器

安装服务:

#opkg install git

#opkg install shadow-useradd shadow-su

执行命令:

#useradd git && passwd git

#vi /etc/passwd

git:x:32769:32769::/opt/git:/usr/bin/git-shell

#vi /etc/shells

/bin/ash
/usr/bin/git-shell

新建/opt/git rwxr—–权限

新建/opt/git/.ssh rwxr—–权限

#su git

#dropbearkey -t rsa -s 1024 -f ~/.ssh/dropbear_rsa_host_key
#dropbearkey -y -f ~/.ssh/dropbear_rsa_host_key >> ~/.ssh/authorized_keys

authorized_keys rw-r–r–权限

将其他机器公钥放到要免密登录的机器~/.ssh/authorized_keys下

git init –bare xxx项目目录

使用 acme 工具免费申请 SSL 证书

#curl https://get.acme.sh | sh

#vim ~/.bashrc

export CF_Key=”your_cloudflare_api_key”

export CF_Email=”your_email_address”

#source ~/.bashrc

#acme.sh –register-account -m [email protected] acme.sh –issue –dns dns_cf -d your_domain.com –debug

#acme.sh –install-cert -d your_domain.com –key-file /home/user/.acme.sh/your_domain.com_ecc/your_domain.com.key –fullchain-file /home/user/.acme.sh/your_domain.com_ecc/your_domain.com.cer –reloadcmd “sudo nginx -s reload”

nignx 直播流

  1. sudo apt update
  2. sudo apt install libnginx-mod-rtmp

打开配置文件nginx.conf,添加RTMP的配置。

rtmp {
server {
listen 1935;
chunk_size 4096;
application vod {
play /mnt/HDD80/vod;
}
application live {
live on;
record all;
record_unique on;
record_interval 5m;
record_suffix .mp4;
record_path /mnt/HDD80/record;
}

}
}

location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}

location /stat.xsl { 
    root /usr/share/doc/libnginx-mod-rtmp/examples/;
}

Git设置代理

有时会国内会因为github克隆速度非常慢,中途各种错误断开造成克隆项目失败,可以尝试设置代理解决
设置代理

1.http || https协议

//设置全局代理
//http
git config --global https.proxy http://127.0.0.1:1080
//https
git config --global https.proxy https://127.0.0.1:1080
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

//只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
//取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

//取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy

2.SSH协议


Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p

Host github.com
User git
ProxyCommand connect -H 127.0.0.1:1080 %h %p

code-server搭建

Ubuntu 使用下面代码安装:

curl -fsSL https://code-server.dev/install.sh | sh
配置守护进程
vim /usr/lib/systemd/system/code-server.service

输入以下配置

[Unit]
Description=code-server
After=network.target
[Service]
Type=exec
Environment=HOME=/root
ExecStart=/usr/bin/code-server
Restart=always
然后就可以通过以下命令来启动和关闭code-server服务了
start code-server
systemctl start code-server
stop code-server
systemctl stop code-server
code-server status
systemctl status code-server

开启SSL:

vim /root/.config/code-server/config.yaml

cert: /xxxx.crt

cert-key: /xxx.key

Jquery QRCode

GitHub – jeromeetienne/jquery-qrcode: qrcode generation standalone (doesn’t depend on external services)

How to Use It

Let me walk you thru it. First include it in your webpage with the usual script tag

<script type="text/javascript" src="jquery.qrcode.min.js"></script>

Then create a DOM element which gonna contains the generated qrcode image. Lets say a div

<div id="qrcode"></div>

Then you add the qrcode in this container by

jquery('#qrcode').qrcode("this plugin is great");

This is it. see it live.

You can set the height and width of the generated qrcode:

jquery('#qrcode').qrcode({width: 64,height: 64,text: "size doesn't matter"});

比较有特点的订单号

<?php
$yCode=array_merge(range('A', 'Z'),range('a', 'z'),range(0, 9));
$orderSn = $yCode[intval(date('Y')) - 2023];
$orderSn .= $yCode[intval(date('m'))];
$orderSn .= $yCode[intval(date('d'))];
$orderSn .= $yCode[intval(date('H'))];
$orderSn .= $yCode[intval(date('i'))];
$orderSn .= $yCode[intval(date('s'))];
$orderSn .=  substr(microtime(), 2, 5)
$orderSn .=  sprintf('%02d', mt_rand(0, 99));
echo $orderSn;

OpenWrt Aria2开启SSL

在Aria2设置中将 配置文件目录改为 :/opt/aria2

上传证书文件至/opt/aria2

编辑/etc/init.d/aria2 查找append_setting “xxxxxxxxxxxxxxxxx” 在后面一行添加

append_setting "rpc-secure=true"
append_setting "rpc-certificate=$config_dir/uhttpd.crt"
append_setting "rpc-private-key=$config_dir/uhttpd.key"

重启Aria2即可