Fork me on GitHub
0%

使用

1
cat /proc/mounts

获取挂载选项并填入/etc/fstab中.

torch1.6版本中,对torch.save进行了更改.The 1.6 release of PyTorch switched torch.save to use a new zipfile-based file format. torch.load still retains the ability to load files in the old format. If for any reason you want torch.save to use the old format, pass the kwarg _use_new_zipfile_serialization=False.

方法1

升级pytorch到1.6版

方法2

使用pytorch读入,再保存

1
2
3
4
5
6
device = 'cuda'
net = model()
saved_net = torch.load("nozip.pth", map_location=device)
net.load_state_dict(saved_net)
net.to(device=device)
torch.save(net.state_dict(), 'nozip.pth', _use_new_zipfile_serialization=False)

安装所需版本的gcc和g++

1
sudo apt install gcc-5 g++-5

执行如下指令

1
2
3
4
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 8

此处假设原版本为7

执行如下指命更换版本

1
2
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

输入

1
ls
获取可用的磁盘, 如(hd0,gpt1)之类的. 然后输入
1
ls (hd0,gpt1)/
查看磁盘内的文件路径, 找到grub所在的路径, 如(hd0,gpt1)/boot/grub或(hd0,gpt1)/grub)或(hd0,gpt1)/EFI/boot/grub或(hd0,gpt1)/EFI/grub, 然后输入
1
set
查看root和prefix的内容, 确定要修改的变量. 确定了之后使用如下命令:
1
2
3
4
5
set prefix=(hd0,gpt1)/grub
set root=(hd0,gpt1)
insmod linux
insmod normal
normal
此时应该可以正常启动了 在进入系统后打开terminal, 使用命令:
1
sudo update-grub
修复即可

首先按这里使用docker部署seafile 注意将映射到宿主机的端口换成80以外的端口(如81),避免与后面的caddy冲突 启动后在浏览器登录,在"头像"->"系统管理"->"设置"中,将"FILE_SERVER_ROOT"中的域名换成ip地址,就可以上传下载文件了. 还有两步验证什么的.

docker-compose的一些常用命令:

1
2
3
4
5
docker-compose up -d
docker-compose down #销毁
docker-compose start
docker-compose stop
docker-compose ps #查看docker镜像

然后安装caddy,生成证书

1
2
3
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /"     | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
sudo apt install caddy
openssl req -x509 -newkey rsa:2048 -sha256 -nodes -keyout key.pem -out cert.pem -days 3650 -subj "/CN=****"
****为ip地址 Caddyfile:
1
2
3
4
5
6
7
8
9
:443 {
tls cert.pem key.pem
reverse_proxy 127.0.0.1:81
}

:444 {
tls cert.pem key.pem
reverse_proxy 127.0.0.1:82
} #假如有其他端口也要使用https
****为ip地址

然后,

1
2
caddy run   #测试是否正常
caddy start #后台运行
根据这里配置fail2ban,由于https是用caddy在docker外实现的,因此iptables可以正常起作用.

根据这里设置seafile的nginx和seahub_settings.py,其中nginx的ip地址改为网卡docker0的ip,端口为onlyoffice在宿主机的端口,在本文中为780.

然后在seafile的docker-compose.yml中加入:

1
2
3
4
5
6
7
8
9
onlyofficeds:
image: onlyoffice/documentserver:latest
container_name: oods
ports:
- "780:80"
volumes:
- /root/seafile/oods/default.json:/etc/onlyoffice/documentserver/default.json
networks:
- oods-net
并在文件末尾的networks:处改为:
1
2
3
networks:
seafile-net:
oods-net:

其中default.json文件那行可以先不写,运行容器的时候从容器中复制一份出来之后找到rejectUnauthorized并改为false.(使用了自签名证书时需要此步) 也可以在容器内执行:

1
/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'

或者,使用snap部署onlyoffice: 首先根据这里安装snap. 然后依次执行:

1
2
3
snap install onlyoffice-ds
snap set onlyoffice-ds onlyoffice.ds-port=780
vi /var/snap/onlyoffice-ds/current/etc/onlyoffice/documentserver/default.json
将rejectUnauthorized改为false即可.

最后,在caddy配置文件中加入

1
2
3
basicauth /onlyofficeds/* {
用户名 hash
}

ISO文件放在某个分区的根目录,在本文中是sda7,ushendu在sda8

修改文件/etc/grub.d/40_custom(不要直接改文件/boot/grub/grub.cfg),加上以下几行

1
2
3
4
5
6
7
8
9
10
11
12
menuentry "Debian live" {
set isofile="/debian-live-10.2.0-amd64-xfce.iso"
loopback loop (hd0,7)$isofile
linux (loop)/live/vmlinuz-4.19.0-6-amd64 boot=live config union=overlay username=user components noswap noeject vga=788 ip= net.ifnames=0 toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img-4.19.0-6-amd64
}
menuentry "UShenDu" --class windows --class os {
insmod part_gpt
insmod fat
set root='hd0,gpt8'
chainloader /EFI/boot/bootx64.efi
}
1
sudo update-grub

1
cd /etc/NetworkManager/system-connections

使用 cat 命令查看 Linux 中已保存的 WiFi 配置文件,在 WiFi-Security 段的 psk 位置可以查看到无线密码。

Enable and disable

1
2
sudo ufw enable
sudo ufw disable

Check the status of UFW

1
2
sudo ufw status verbose
sudo ufw status

Add rules

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo ufw allow 53
sudo ufw allow 53/tcp
sudo ufw deny 53
sudo ufw deny 53/tcp
sudo ufw allow 7100:7200/tcp
sudo ufw allow ssh
sudo ufw deny ssh
sudo ufw allow from 207.46.232.182
sudo ufw allow from 192.168.1.0/24
sudo ufw allow from 192.168.0.4 to any port 22
sudo ufw allow from 192.168.0.4 to any port 22 proto tcp
sudo ufw allow in on eth0 to any port 80
sudo ufw allow in on eth0 from 192.168.0.0/16

Delete rules

Add 'delete' after 'ufw' in the above command.

1
2
sudo ufw delete deny 80/tcp
sudo ufw delete allow ssh

Reset

1
sudo ufw reset

编写脚本

编写一个脚本mount-sda6.service,放在/etc/systemd/system/下

1
2
3
4
5
6
7
8
[Unit]
Description=mount sda6 for backup

[Service]
ExecStart=/bin/bash -c "mount -o compress=zstd /dev/sda6 /media/backup"

[Install]
WantedBy=multi-user.target
如果ExecStart中运行了某个脚本,记得要赋于脚本运行权限(chmod +x)。

查看当前的状态

使用systemctl list-unit-files --type=service命令。

1
sudo systemctl list-unit-files --type=service|grep mount-sda6
出现如下内容即为正常。
1
mount-sda6.service                         disabled

enable服务后使之start

加入开机自启动

1
sudo systemctl enable mount-sda6

马上运行该服务

1
sudo systemctl start mount-sda6

查看运行状态

1
sudo systemctl status mount-sda6

显示如下:

1
2
3
4
5
   Loaded: loaded (/etc/systemd/system/mount-sda6.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2019-12-13 22:11:32 CST; 12h ago
Main PID: 939 (code=exited, status=0/SUCCESS)

12月 13 22:11:32 ki-PC systemd[1]: Started mount sda6 for backup.

重启,查看服务是否正常自动启动

1
sudo reboot