标签 config 下的文章

执行lsblk命令查看能否正常识别mmcblk1分区,若不能识别则无法刷入emmc

install.sh文件代码如下

#!/bin/sh
 
echo "Start script create MBR and filesystem"
 
DEV_EMMC=/dev/mmcblk1
 
echo "Start backup u-boot default"
 
dd if="${DEV_EMMC}" of=/boot/u-boot-default.img bs=1M count=4
 
echo "Start create MBR and partittion"
 
parted -s "${DEV_EMMC}" mklabel msdos
# `bootloader` / `reserved` occupies [0, 100M).
# Sector size is 512B.
parted -s "${DEV_EMMC}" unit s mkpart primary fat32 204800 466943  # [100M, 228M)
parted -s "${DEV_EMMC}" unit s mkpart primary ext4 466944 100%     # [228M, ...]
 
echo "Start restore u-boot"
 
dd if=/boot/u-boot-default.img of="${DEV_EMMC}" conv=fsync bs=1 count=442
dd if=/boot/u-boot-default.img of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1
 
sync
 
echo "Done"
 
echo "Start copy system for eMMC."
 
mkdir -p /ddbr
chmod 777 /ddbr
 
PART_BOOT="/dev/mmcblk1p1"
PART_ROOT="/dev/mmcblk1p2"
DIR_INSTALL="/ddbr/install"
 
if [ -d $DIR_INSTALL ] ; then
    rm -rf $DIR_INSTALL
fi
mkdir -p $DIR_INSTALL
 
if grep -q $PART_BOOT /proc/mounts ; then
    echo "Unmounting BOOT partiton."
    umount -f $PART_BOOT
fi
echo -n "Formatting BOOT partition..."
mkfs.vfat -n "BOOT_EMMC" $PART_BOOT
echo "done."
 
mount -o rw $PART_BOOT $DIR_INSTALL
 
echo -n "Cppying BOOT..."
cp -r /boot/* $DIR_INSTALL && sync
echo "done."
 
echo -n "Edit init config..."
sed -e "s/ROOTFS/ROOT_EMMC/g" \
 -i "$DIR_INSTALL/uEnv.ini"
echo "done."
 
rm $DIR_INSTALL/s9*
rm $DIR_INSTALL/aml*
rm -rf $DIR_INSTALL/n1*
 
umount $DIR_INSTALL
 
if grep -q $PART_ROOT /proc/mounts ; then
    echo "Unmounting ROOT partiton."
    umount -f $PART_ROOT
fi
 
if [ -e /boot/n1-logo.img ] ; then
# The logo should be no greater than 8M. (It's less than 5M in my case.)
echo "Installing Ubuntu logo..."
dd if=/boot/n1-logo.img of=/dev/mmcblk1 bs=1M seek=644
echo "done."
fi
 
echo "Formatting ROOT partition..."
# 0x27400000 ~ +0x800000 is used by `/dev/env`. Mark them as bad blocks
# so that they won't be used by Linux. (It seems that they're overwritten
# each time system boots if invalid.)
#
# As `ROOT_EMMC` starts from 228M, offset of `/dev/env` in this partition
# is 400M.
#
# Here we generates a sequence of block number in range [400M, 408M), with
# block size = 4K, and pass them as bad blocks to `mke2fs`.
#
# Given that we're using 4K blocks, the mapped block number will be [102400,
# 104448), or [102400, 104447].
#
# `/dev/logo` is in range [644M, 772M) (of the whole `/dev/mmcblk1`, not this
# partition. Minus 228M yourself.). Mark them as bad blocks if you want to
# preserve or replace the boot logo.
#
# All other partitions (`recovery`, `rsv`, `tee`, `crypt`, `misc`, `boot`,
# `system`, `data` is already overwritten by the original script, as it
# places the first partition at 700M.)
echo "Marked blocks used by /dev/env as bad to protected them from being overwritten."
seq 102400 104447 > /tmp/reservedblks
if [ -e /boot/n1-logo.img ] ; then
echo "Marked blocks used by /dev/logo as bad."
seq 106496 108543 >> /tmp/reservedblks  # Only first 8M of `/dev/logo` is reserved.
fi
mke2fs -F -q -t ext4 -L ROOT_EMMC -m 0 $PART_ROOT -b 4096 -l /tmp/reservedblks
e2fsck -n $PART_ROOT
echo "done."
 
echo "Copying ROOTFS."
 
mount -o rw $PART_ROOT $DIR_INSTALL
 
cd /
echo "Copy BIN"
tar -cf - bin | (cd $DIR_INSTALL; tar -xpf -)
#echo "Copy BOOT"
#mkdir -p $DIR_INSTALL/boot
#tar -cf - boot | (cd $DIR_INSTALL; tar -xpf -)
echo "Create DEV"
mkdir -p $DIR_INSTALL/dev
#tar -cf - dev | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy ETC"
tar -cf - etc | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy HOME"
tar -cf - home | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy LIB"
tar -cf - lib | (cd $DIR_INSTALL; tar -xpf -)
echo "Create MEDIA"
mkdir -p $DIR_INSTALL/media
#tar -cf - media | (cd $DIR_INSTALL; tar -xpf -)
echo "Create MNT"
mkdir -p $DIR_INSTALL/mnt
#tar -cf - mnt | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy OPT"
tar -cf - opt | (cd $DIR_INSTALL; tar -xpf -)
echo "Create PROC"
mkdir -p $DIR_INSTALL/proc
echo "Copy ROOT"
tar -cf - root | (cd $DIR_INSTALL; tar -xpf -)
echo "Create RUN"
mkdir -p $DIR_INSTALL/run
echo "Copy SBIN"
tar -cf - sbin | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy SELINUX"
tar -cf - selinux | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy SRV"
tar -cf - srv | (cd $DIR_INSTALL; tar -xpf -)
echo "Create SYS"
mkdir -p $DIR_INSTALL/sys
echo "Create TMP"
mkdir -p $DIR_INSTALL/tmp
echo "Copy USR"
tar -cf - usr | (cd $DIR_INSTALL; tar -xpf -)
echo "Copy VAR"
tar -cf - var | (cd $DIR_INSTALL; tar -xpf -)
 
echo "Copy fstab"
 
rm $DIR_INSTALL/etc/fstab
cp -a /root/fstab $DIR_INSTALL/etc/fstab
 
rm $DIR_INSTALL/root/install.sh
rm $DIR_INSTALL/root/fstab
rm $DIR_INSTALL/usr/bin/ddbr
rm $DIR_INSTALL/usr/bin/ddbr_backup_nand
rm $DIR_INSTALL/usr/bin/ddbr_backup_nand_full
rm $DIR_INSTALL/usr/bin/ddbr_restore_nand
 
 
cd /
sync
 
umount $DIR_INSTALL
 
echo "*******************************************"
echo "Complete copy OS to eMMC "
echo "*******************************************"

执行shutdown now关机断电,拔掉u盘后插电即可直接进入armbian

参考:
https://www.leonlu.cc/hobby/note005-phicomm-p1-linux/
https://isolated.site/2018/12/08/my-script-for-installing-armbian-5-67-into-phicomm-n1/

前端搭建

https://docs.v2board.com/deploy/aapanel.html
按照官方教程操作
避免出现问题 最好使用全新重装的系统按步骤操作 大佬随意
出现玄学的问题reboot重启vps也许就解决了

每次修改 .env 文件后需要执行以下命令重建缓存
php artisan config:cache

500错误尝试重新给予目录权限 在站点域名目录下执行
chown -R www:www *

后端搭建

https://github.com/ColetteContreras/v2ray-poseidon/wiki/0201-%E5%AF%B9%E6%8E%A5-V2board-%E6%95%99%E7%A8%8B

#一键脚本
curl -L -s https://raw.githubusercontent.com/ColetteContreras/v2ray-poseidon/master/install-release.sh | bash
#删除配置文件
rm /etc/v2ray/config.json
编辑配置文件
vi /etc/v2ray/config.json
重启v2ray
service v2ray restart

传输协议 伪装域名和路径的配置示例

{
    "path": "/路径",
    "headers": {
      "Host": "域名"
    }
}

换源

vi /etc/apt/sources.list

deb https://mirrors.ustc.edu.cn/debian stretch main contrib non-free
deb https://mirrors.ustc.edu.cn/debian stretch-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian stretch-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ stretch/updates main contrib non-free

apt-get update && apt-get upgrade

安装宝塔

https://www.feiji.work/2019/20.html
wget https://www.feiji.work/n1/bt/6.9.4/install.sh && sudo bash install.sh
安装完成可能有错误提示 直接reboot重启
查看面板入口:/etc/init.d/bt default

安装nginx

https://www.feiji.work/2019/41.html

打开ssh(注:如果以下步骤提示缺少文件,可以在宝塔后台执行一次安装Nginx,在下载完脚本后直接取消安装即可。)

cd /www/server/panel/install #如果目录存在nginx 先rm
wget https://www.feiji.work/n1/bt/nginx.sh 下载nginx.sh
sh nginx.sh install #直接安装

安装Nginx出现checking for GD library ... not found错误
https://de.lib.im/linux-gd.html
apt-get -y install libgd2-xpm-dev build-essential重新安装

报错Starting nginx... nginx: [emerg] getpwnam("www") failed in /www/server/nginx/conf/nginx.conf:1
https://blog.csdn.net/rebel_yangke/article/details/58601731
修改/www/server/nginx/conf/nginx.conf 两个www改成root 再重启

pppoe宽带拨号

https://xaolong.com/post/279.html
https://malagege.github.io/blog/2019/01/26/Linux%E4%BD%BF%E7%94%A8pppoe%E9%80%A3%E7%B7%9A%E6%96%B9%E6%B3%95%E5%B0%8F%E8%A8%98/

apt install pppoeconf -y
apt install isc-dhcp-server -y

vi /etc/default/isc-dhcp-server
#将INTERFACESv4=""修改为INTERFACESv4="br0"
#在INTERFACESv6=""的前面加个#,修改为#INTERFACESv6=""

mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak

vi /etc/dhcp/dhcpd.conf  ###里面的所有内容
###
option domain-name "phicomm-n1";
option domain-name-servers 119.29.29.29;
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.101 192.168.1.254;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.2;
    option domain-name-servers 119.29.29.29;
}
default-lease-time 600;
max-lease-time 7200;
authoritative;
###

vi /etc/network/interfaces
#iface eth0 inet dhcp 改为iface eth0 inet manual 后面增加以下内容 ###里面的全部 见图一
###
auto br0
iface br0 inet static
bridge_ports eth0
address 192.168.1.2
broadcast 192.168.1.255
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.2
bridge_stp off              
bridge_waitport 0           
bridge_fd 0
###

vi /etc/sysctl.conf
#去掉net.ipv4.ip_forward=1前面的#号

sysctl -p

vi  /etc/rc.local
#在 exit 0 前一行加以下内容
iptables -t nat -A POSTROUTING -j MASQUERADE

reboot

批注 2019-12-29 185147.png

n1接光猫 #n1已经固定IP 192.168.1.2

pppoeconf #进入拨号向导
#第一个选no
#删除username 输入宽带账号
#输入宽带密码
#之后全部 yes

poff -a # 關閉全部pppoe

查看状态
plog
ip addr show ppp0

开机自动拨号
vi /etc/rc.local #在 exit 0 前一行加一句:
pon dsl-provider

账号密码配置文件地址/etc/ppp/pap-secrets

动态域名解析dns

https://github.com/NewFuture/DDNS

git clone https://github.com/NewFuture/DDNS
cd DDNS
./run.py #运行一次 生成config.json配置文件
vi config.json #修改 id 域名 token
./task.sh

说明:电信的iTV机顶盒,教程完毕后不破坏原有功能,不完美的是不能直接安装apk。IP用的静态IP
有知道如何可以直接安装软件的大佬麻烦告知下
TIM截图20190702002759.png
TIM截图20190702002820.png

准备工具

U盘先下载好自己需要的app 如当贝桌面
ADB组件下载:http://cdn.tvapk.com/zndsjc/adb.zip #解压到c盘根目录
ADB密码计算器下载:http://cdn.tvapk.com/zndsrom/app/zikaikeji.apk #安装在手机

打开adb

进入中兴盒子的设置,一般密码为:6321,连接网线或wifi(机顶盒和电脑处于同个网段),接着选择运维调试—打开ADB调试,然后手机打开ADB密码计算器,将对应的MAC地址与随机数填入
TIM截图20190702003825.png

cmd操作

按下键盘快捷键“WIN+R”,输入“cmd”确定,进入命令终端

cd c:/adb #切换到目录下
adb connect 192.168.123.12 #输入自己盒子的IP
adb shell
setprop config.Android.AppInstallCtrl 3
mount -o remount -o rw /system
echo "setprop config.Android.AppInstallCtrl 3" >> /system/bin/init.zte.post_boot.sh
echo "start adbd" >> /system/bin/init.zte.post_boot.sh
echo "adbd&" >> /system/bin/init.zte.post_boot.sh

df #查看自己U盘的路径 如:/storage/external_storage/sda1/
cd /storage/external_storage/sda1/ #进入目录
ls #列出当前目录下的所有文件
cp *.apk /data/app #复制当前目录下的所有apk文件到机顶盒目录(安装软件)
am start com.dangbei.tvlauncher #启用当贝桌面

参考:https://www.znds.com/jc/article/7408-1.html

说明:telegram的mtproto最近挂得很快,搜索了下发现用国内机子中转下,同时找到了inner-ss。下面是国内小鸡上的操作,国外的酸酸正常使用的情况。
不仅仅电报可以用,老毛子固件的transocks应该也行,配合gfwlist

1.下载自己服务器对应的版本 https://github.com/ihciah/inner-shadowsocks/releases
2.上传到服务器目录下/root/inner-ss/ 只是举例,按自己实际情况
3.编辑config.json

{
  "listen": "0.0.0.0",
  "port": 23333, #socks5的端口
  "auth": false, #认证默认关闭
  "username": "ihc", #用户名
  "password": "iah", #密码
  "servers": ["ss://RC4-MD5:pass1@ip1:port1", "ss://RC4-MD5:pass2@ip2:port2"], #酸酸服务器
  "maxfail": 3,
  "recovertime": 600,
  "starttimeout": 3,
  "remotetimeout": 120,
  "insidetimeout": 120,
  "whitelistenable": false,
  "whitelistdomains": [".telegram.org"],
  "whitelistips": ["::/0", "0.0.0.0/0", "91.108.4.0/22", "91.108.8.0/22", "91.108.56.0/22", "109.239.140.0/24", "149.154.160.0/20", "149.154.164.0/22", "2001:67c:4e8::/48"]
}

4.开机启动后台运行(Debian8)
vi /etc/rc.local
在"exit 0"前添加一行
nohup /root/inner-ss/inner-ss -c /root/inner-ss/config.json > /dev/null 2>&1 &
给权限
chmod +x /etc/rc.local

菜鸟一枚,根据自己操作写的记录贴,有不当的地方请指出

下载v2ray

下载地址:https://github.com/v2ray/v2ray-core/releases/
r2d选择arm:https://github.com/v2ray/v2ray-core/releases/download/v3.43/v2ray-linux-arm.zip

上传至路由器

目录:根据自己实际情况,之前又mt工具箱,所以直接放里面了
/data/etc/misstar/applications/v2ray
1.解压上传客户端文件

2.上传客户端配置文件
2.1导出客户端配置并上传至路由器
image

2.2修改配置文件,参考下面代码

{
  "log": {
    "access": "",
    "error": "error.log", 
    "loglevel": "warning"
  },
  "inbound": {
    "port": 2333,
    "listen": "0.0.0.0",
    "protocol": "socks",
    "domainOverride": [
      "tls",
      "http"
    ],
    "settings": {
      "auth": "noauth",
      "udp": true,
      "ip": "127.0.0.1",
      "clients": null
    },
    "streamSettings": null
  },
  "outbound": {
    "tag": "agentout",
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "us2.sangyu.tw",
          "port": 443,
          "users": [
            {
              "id": "xxxxxxxxxxxxxxxxxxx",
              "alterId": 233,
              "email": "t@t.tt",
              "security": "aes-128-gcm"
            }
          ]
        }
      ],
      "servers": null
    },
    "streamSettings": {
      "network": "ws",
      "security": "tls",
      "tlsSettings": {
        "allowInsecure": true,
        "serverName": null
      },
      "tcpSettings": null,
      "kcpSettings": null,
      "wsSettings": {
        "connectionReuse": true,
        "path": "/",
        "headers": {
          "Host": "us2.sangyu.tw"
        }
      },
      "httpSettings": null
    },
    "mux": {
      "enabled": true
    }
  },
    "inboundDetour":[
        {
           "protocol":"dokodemo-door",
           "port":1099, 
           "settings":{
              "address":"",
              "network":"tcp",
              "timeout":0,
              "followRedirect":true
           }
        }
     ],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {
        "response": null
      },
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockout"
    }
  ],
  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "port": null,
          "outboundTag": "direct",
          "ip": null,
          "domain": [
            "geosite:cn"
          ]
        },
        {
          "type": "field",
          "port": null,
          "outboundTag": "direct",
          "ip": [
            "geoip:cn"
          ],
          "domain": null
        },
        {
          "type": "field",
          "port": null,
          "outboundTag": "direct",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "domain": null
        }
      ]
    }
  }
}

运行软件

1.切换到目录下:/data/etc/misstar/applications/v2ray
2.赋予权限:

chmod +x /data/etc/misstar/applications/v2ray/v2ray
chmod +x /data/etc/misstar/applications/v2ray/v2ctl

3../v2ray --config=/data/etc/misstar/applications/v2ray/config.json
后台运行nohup /data/etc/misstar/applications/v2ray/v2ray --config=/data/etc/misstar/applications/v2ray/config.json &

参考:
https://ralf.ren/717
https://cloverkit.coding.me/2018/08/07/配置-V2Ray-和路由器透明代理

基本介绍

路由器:r2d
工具箱:Misstar Tools 版本:3.18.09.10
插件:frp
故障描述:frp无法正常启动,本人菜鸟,无法获取更多的错误信息,工具箱群里问了下没人回,还好搜索有解决办法,就搬过来了。

更新路由器中的frp

1.下载最新版frp:https://github.com/fatedier/frp/releases
当前的最新版下载地址:https://github.com/fatedier/frp/releases/download/v0.21.0/frp_0.21.0_linux_arm.tar.gz

2.解压下载的文件,替换/data/etc/misstar/applications/frp/bin中的frpc

3.更改frp配置信息
vi /data/etc/misstar/applications/frp/script/frp #编辑配置文件
修改第32行echo "privilege_token = "$privilege_token >> /etc/misstar/applications/frp/config/frpc.confecho "token = "$privilege_token >> /etc/misstar/applications/frp/config/frpc.conf
在下一行增加两行frpc运行时生成日志,方便出问题时的排查:

    echo >> /etc/misstar/applications/frp/config/frpc.conf
    echo "log_file = /etc/misstar/applications/frp/bin/frpc.log" >> /etc/misstar/applications/frp/config/frpc.conf

文件最后加上restart 的脚本

restart(){
        stop; sleep 2; start
}

赋予执行权限:chmod +x /data/etc/misstar/applications/frp/script/frp
[工具箱配置完成后]试一下看能不能启动 frpc:./frp start

更新服务端frp

./install-frps.sh update
我当时路由器用最新版 而vps用0.16.0的时候就会出现这样的错误login to server failed: EOF

image

参考:http://bbs.xiaomi.cn/t-32690007

1、依赖安装

apt-get update
apt-get install git wget python-setuptools -y
apt-get install python-pip
pip install cymysql

2、libsodium 安装

apt-get install build-essential -y
wget https://github.com/jedisct1/libsodium/releases/download/1.0.16/libsodium-1.0.16.tar.gz
tar xf libsodium-1.0.16.tar.gz && cd libsodium-1.0.16
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
cd ../ && rm -rf libsodium*

3、下载源代码并安装依赖

git clone -b manyuser https://github.com/Anankke/shadowsocks.git
cd shadowsocks
pip install -r requirements.txt

4、配置文件

cp apiconfig.py userapiconfig.py
cp config.json user-config.json
vi userapiconfig.py

5、运行SSR

python server.py 用于调试的
./run.sh 无日志后台运行
./logrun.sh 有日志后台运行

6、开机启动
假设你的shadowsocks是安装在root目录下,可以这样:
vi /etc/rc.local
加入一条:
sh /root/shadowsocks/run.sh
然后:
chmod +x /etc/rc.local
Debian 9开机启动 https://sixu.life/debian-9-etc-rc-local.html
7、使用Supervisor守护进程启动ssr

# 安装
apt-get install supervisor -y

# 写入配置
vi /etc/supervisor/conf.d/ssr.conf

# 写入以下内容
[program:ssr]
command=python /root/shadowsocks/server.py 
autorestart=true
autostart=true
user=root

# 重启Supervisor服务。
/etc/init.d/supervisor restart

# 重启 ssr
supervisorctl restart ssr

# 查看Supervisor服务运行状态。
supervisorctl status

# 如果遇到问题,可以检查日志:
supervisorctl tail -f ssr stderr

# 如果使用supervisor进程守护,需要修改文件vi /etc/default/supervisor,添加一行:
ulimit -n 1024000

8、加速
Debian OpenVZ 魔改 BBR:https://sixu.life/debian-openvz-magic-change-bbr.html
Debian centos bbr加速:https://sixu.life/the-acceleration-effect-of-bbr-is-obvious.html

参考:
https://blog.starryvoid.com/archives/176.html

https://github.com/zyl6698/ss-panel-v3-mod-with-f2fpay/wiki/%E5%AE%89%E8%A3%85%E9%AD%94%E6%94%B9%E5%90%8E%E7%AB%AF

https://github.com/iMeiji/shadowsocks_install/wiki/%E6%90%AD%E5%BB%BA-sspanel-v3-%E9%AD%94%E6%94%B9%E7%89%88%E8%AE%B0%E5%BD%95