一些下载工具

站点 工具 GO 版本
twitter https://chrome.google.com/webstore/detail/twitter-media-downloader/cblpjenafgeohmnjknfhpdbdljfkndig 单元格
instagram https://github.com/cakturk/instaget 单元格
douyin https://github.com/XiyaoWong/spiders -

docker install

docker push atchen1988/jenkins

我的 docker 已经配置好了 GO 环境

或者用官方的 docker

一些说明

如果想用 root 用户进去配置东西,执行

docker exec -u 0 -it ea8ba5bc923b bash

如果想用官方版,配置笔记如下

# 换源
cat /etc/issue

apt-get install -y vim
apt-get install -y make

# install
  go get -u github.com/cute-angelia/protobuf/protoc-gen-go
# install protoc
	http://google.github.io/proto-lens/installing-protoc.html
	PROTOC_ZIP=protoc-3.7.1-linux-x86_64.zip
	curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
	unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
	unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
	rm -f $PROTOC_ZIP
# install protoc-gen-micro
	https://github.com/micro/protoc-gen-micro
  go get github.com/micro/protoc-gen-micro

vim ~/.profile  or  ~/.bashrc
export PATH=$PATH:/usr/local/go/bin:/root/go/bin
export GOPATH=/root/go
export GOROOT=/usr/local/go
export GOPROXY=https://goproxy.cn
export GO111MODULE=on

export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

shell

项目把 proto服务 包括进去了, 不像某些项目,微服务都是独立一个特项目,所以,我这边会根据提交的 comment 进行匹配

仅供参考

#!/bin/bash

pwd

group="qiming"
project_name=$(echo $GIT_URL | awk -F/ '{print $NF}' | sed 's/.git//g')

export GOPROXY=https://goproxy.io
export GOROOT=/usr/local/go
export GOPATH=/var/jenkins_home/$group/gopath
mkdir -p $GOPATH $GOPATH/src

# 初次
rm -rf $GOPATH/src/$project_name
ln -f -s $WORKSPACE $GOPATH/src/$project_name

cd $GOPATH/src/$project_name && make proto

cd $GOPATH/src/$project_name

comment=$(git log -1 --pretty=%B)
branch=${GIT_BRANCH#*origin/}

echo "========== 处理分支:${branch}, 项目:${comment} =========="

if [ "${comment}" == "svr-monitor" ]; then

    # 本地服务根路径
    rootpath="$GOPATH/src/$project_name/svr/${comment}"

    cd ${rootpath} && go mod vendor && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build

    chmod +x ${rootpath}/${comment}

	dest="/app/data/qiming-service/${comment}/${comment}/"

    echo '{
    "apps": [{
    "name": "qm-'${comment}'",
    "script": "'${comment}'",
    "cwd": "${dest}",
    "args": ["--registry=consul"],
    "env": {},
    "node_args": [],
    "log_date_format": "YYYY-MM-DD HH:mm Z",
    "exec_interpreter": "none",
    "exec_mode": "fork",
    "max_memory_restart": "300M"
    }]
    }' > ${rootpath}/pm2_${branch}.json


    if [ "${branch}" == "prerelease" ] || [ "${branch}" == "master" ]; then
      if [ "${branch}" == "prerelease" ]; then
        ansible mali-test -u gouser -a "mkdir -p ${dest}"
        ansible mali-test -u gouser -m copy -a "src=${rootpath}/pm2_${branch}.json dest=${dest}"
        ansible mali-test -u gouser -m copy -a "src=${rootpath}/${comment} dest=${dest}"
        ansible mali-test -u gouser -a "/app/pkg/node-v12.0.0-linux-x64/bin/node /app/pkg/node-v12.0.0-linux-x64/bin/pm2 startOrReload ${dest}/pm2_${branch}.json"
        echo "${branch} publish ok:${comment}"
      else
        echo "${branch}该分支还未发布到线上, 目前是测试环境,请用 prerelease 分支"
      fi
    else
      echo "${branch}该分支不自动发布"
    fi
fi

安装 dlna 让局域网电视机观看 lede 影片

安装

opkg update
opkg install minidlna

// 可选
opkg install luci-app-minidlna

配置文件

vim /etc/config/minidlna

#------------------------------------------------------#
# port for HTTP (descriptions, SOAP, media transfer) traffic
#------------------------------------------------------#
port=8200

#------------------------------------------------------#
# network interfaces to serve, comma delimited
#------------------------------------------------------#
network_interface=br-lan

#------------------------------------------------------#
# set this to the directory you want scanned.
# * if have multiple directories, you can have multiple media_dir= lines
# * if you want to restrict a media_dir to a specific content type, you
#   can prepend the type, followed by a comma, to the directory:
#   + "A" for audio  (eg. media_dir=A,/home/jmaggard/Music)
#   + "V" for video  (eg. media_dir=V,/home/jmaggard/Videos)
#   + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
#------------------------------------------------------#
# Directory of media is depend on your storage
#------------------------------------------------------#
media_dir=/mnt/sdb2/downloads
media_dir=/mnt/sda3/downloads
#------------------------------------------------------#
# set this if you want to customize the name that shows up on your clients
#------------------------------------------------------#
friendly_name=DLNA Server

#------------------------------------------------------#
# set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
#------------------------------------------------------#
db_dir=/var/run/minidlna

#------------------------------------------------------#
# set this if you would like to specify the directory where you want MiniDLNA to store its log file
#------------------------------------------------------#
log_dir=/var/log/minidlna

#------------------------------------------------------#
# this should be a list of file names to check for when searching for album art
# note: names should be delimited with a forward slash ("/")
#------------------------------------------------------#
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

#------------------------------------------------------#
# set this to no to disable inotify monitoring to automatically discover new files
# note: the default is yes
#------------------------------------------------------#
inotify=yes

#------------------------------------------------------#
# set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO
#------------------------------------------------------#
enable_tivo=no

#------------------------------------------------------#
# set this to strictly adhere to DLNA standards.
# * This will allow server-side downscaling of very large JPEG images,
#   which may hurt JPEG serving performance on (at least) Sony DLNA products.
#------------------------------------------------------#
strict_dlna=no

#------------------------------------------------------#
# default presentation url is http address on port 80
#------------------------------------------------------#
presentation_url=http://192.168.1.1:8200/

#------------------------------------------------------#
# notify interval in seconds. default is 895 seconds.
#------------------------------------------------------#
notify_interval=900

#------------------------------------------------------#
# serial and model number the daemon will report to clients
# in its XML description
#------------------------------------------------------#
serial=12345678
model_number=1

#------------------------------------------------------#
# specify the path to the MiniSSDPd socket
#------------------------------------------------------#
#minissdpdsocket=/var/run/minissdpd.sock

#------------------------------------------------------#
# use different container as root of the tree
# possible values:
#   + "." - use standard container (this is the default)
#   + "B" - "Browse Directory"
#   + "M" - "Music"
#   + "V" - "Video"
#   + "P" - "Pictures"
# if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
#------------------------------------------------------#
#root_container=.

启动

minidlna -f /etc/config/minidlna

其他

如果 opkg update 不了,修改源

cp /etc/opkg/distfeeds.conf /etc/opkg/distfeeds_bak.conf
vim /etc/opkg/distfeeds.conf

源地址

src/gz openwrt_koolshare_mod_core http://openwrt.rinvay.cc/snapshots/targets/x86/64/packages
src/gz openwrt_koolshare_mod_base http://openwrt.rinvay.cc/snapshots/packages/x86_64/base
src/gz openwrt_koolshare_mod_luci http://openwrt.rinvay.cc/snapshots/packages/x86_64/luci
src/gz openwrt_koolshare_mod_packages http://openwrt.rinvay.cc/snapshots/packages/x86_64/packages
src/gz openwrt_koolshare_mod_routing http://openwrt.rinvay.cc/snapshots/packages/x86_64/routing
src/gz openwrt_koolshare_mod_telephony http://openwrt.rinvay.cc/snapshots/packages/x86_64/telephony

OPENWRT 自动清理内存,lede 自动清理内存

使用 OPENWRT/LEDE 做aria2下载,然后就是使用samba, dlna,共享文件给电视,看电影,也就是做一个家庭媒体中心,不过有些路由器系统中SAMBA共享看电影的时候,内存不断的下降,虽然本质是 LINUX 系统的路由,内存管理方式和 WIN 不一样,但是经过观察,确实不会恢复内存,而且低于 100 后,系统会变慢,登录路由反应都很慢。所以还是有必要自动清理内存。方法如下:

  1. 建立 SH 脚本文件填入如下命令:

$free -le 1846000 这个数字,个人建议是总量的一半

脚本第一个 log > 为覆盖, 防止日志爆炸

#!/bin/sh

used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`

echo "===========================" > /var/log/mem.log
date >> /var/log/mem.log
echo "Memory usage | [Use:${used}KB][Free:${free}KB]" >> /var/log/mem.log

if [ $free -le 1846000 ] ; then
sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches
echo "OK" >> /var/log/mem.log
else
echo "Not required" >> /var/log/mem.log
fi

保存后,放在路由器上,例如保存为以下路径:/root/memclean.sh

  1. 加入任务

修改 /etc/crontabs/root 文件,添加一行, 表示 50 分钟检测一次内存余量,低于 1.8G 就清理!!

*/50 * * * * /root/memclean.sh