Entware-ng 是一个适用于嵌入式系统的软件包库,使用 opkg 包管理系统进行管理。之前的路由器刷了 Openwrt 之后直接能用命令行安装相关命令,之后的路由器,NAS 也能安装 Entware-ng 。可以将 Entware-ng 想象成嵌入式设备的一个包管理软件,能方便的用来在嵌入式设备上安装软件,现在在官方的源上已经有超过 2000 个软件包。
相关网址:
在群晖上安装
更具体的可以参考我之前的文章
在 QNAP 上安装
和普通 Linux 下的包管理一样,只要输入命令就能够联网下载相关软件。
opkg update
opkg install git
所有软件包列表可以查看 http://pkg.entware.net/binaries/armv7/Packages.html
通过 opkg 安装的软件启动脚本在 /opt/etc/init.d/ 目录
单个启动命令 /opt/etc/init.d/software_name start
pidstat 是 sysstat 工具包含的一个命令,主要用于监控 Linux Kernel 管理的进程资源占用情况,包括 CPU,IO,内存,线程等等。
The pidstat command is used for monitoring individual tasks currently being managed by the Linux kernel.
pidstat 首次运行会显示系统自开机起各项统计,之后运行将显示从上一次运行到该次运行的统计信息。
apt-get install sysstat
pidstat [options] [interval] [times]
常用的参数:
-u
默认参数,显示各个进程的 CPU 统计信息-r
显示各个进程的内存使用情况-d
显示各个进程的 IO 使用-w
显示各个进程的上下文切换-p PID
指定 PID比如常见的每一秒查看 IO 统计,统计 10 次
pidstat -d 1 10
直接运行 pidstat
默认显示所有进程的 CPU 使用信息,等效于 pidstat -u -p ALL
pidstat -u 1 10
pidstat
Result fields:
Following command will display PID memory usage 10 times every 2 seconds:
pidstat -r 2 10
Result fields:
pidstat -d
Result field:
使用 -T [TASK|CHILD|ALL]
来报告打印更详细的信息,默认 pidstat 使用 TASK,表示监控独立的任务信息。
To show CPU, memory, IO:
pidstat -u -p PID
pidstat -r -p PID
pidstat -d -p PID
比如要查看 PID 为 12002 的进程的 CPU 使用情况,并且要查看所有子线程,每隔 1 秒输出一次,输出 10 次,则可以
pidstat -T ALL -u -p 12002 1 10
pidof finds the process id’s(pids) of the names programs.
pidof [name]
pidof chrome
pidof -s chrome
Options:
-s
instructs the program to only return one pid.This post will only list cross-platform softwares I used now. Each software has its own behaviors, and binded with its own shortcut. It takes time to be familiar with it. So I decided to use only cross-platform softwares in daily life in case I have to swith my main System. But it seems fine till now. I am happy with these great softwares.
DescriptionIntelliJ IDEA is a Java integrated development environment for developing computer software. It is developed by JetBrains, and is available as an Apache 2 Licensed community edition, and in a proprietary commercial edition. Both can be used for commercial development.
Open Sources Alternatives:
DescriptionGoogle Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, and was later ported to Linux, macOS, iOS, and Android. The browser is also the main component of Chrome OS, where it serves as the platform for web apps.
Alternatives:
SmartGit is a Git GUI client with support for SVN, GitHub, BitBucket pull requests and comments.
WizNote for Windows/Mac/Linux is a cross-platform cloud based note-taking client.
GoldenDict is an open-source dictionary program that gives translations of words and phrases for different languages. It allows the use of several popular dictionary file formats simultaneously and without conversion. The project aims to create a feature-rich dictionary search program.
[[TeamViewer]] is proprietary software for remote control, desktop sharing, online meetings, web conferencing and file transfer between computers.
pCloud is the secure cloud storage, where you can store, share and work on all your files.
VeraCrypt is a source-available freeware utility used for on-the-fly encryption. It can create a virtual encrypted disk within a file or encrypt a partition or the entire storage device with pre-boot authentication. VeraCrypt is a fork of the discontinued TrueCrypt project.
TagSpaces is an open-source data manager and file navigator. It helps organize files on local drives by adding tags to files. Users get the same user interface to manage their files on different platforms. TagSpaces is compatible with Windows, Linux, Mac, Android, iPhone, Firefox and Chrome.
Calibre is a cross-platform open-source suite of e-book software. Calibre supports organizing existing e-books into virtual libraries, displaying, editing, creating and converting e-books, as well as syncing e-books with a variety of e-readers. Editing books is supported for EPUB and AZW3 formats.
Telegram is a cloud-based instant messaging and voice over IP service developed by Telegram Messenger LLP, a privately held company registered in London, United Kingdom, founded by the Russian entrepreneur Pavel Durov and his brother Nikolai.
[[balenaEtcher]] is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience.
有油猴脚本可以用来修改网页页面,那么相应的也能通过挂载自己的定义的 CSS 来实现对页面的修改。
如果有了这样的概念,那么可以在页面做到,完全修改页面显示的样式,增加背景,移除广告等等事情。
安装扩展
从该站点寻找可用的样式
Update ruby
gem update --system
gem -v
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l
确保只有 gems.ruby-china.com
Bundler
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
bundle install
QNAP CLUB 中淘到很多不错的应用,rtorrent-Pro 就是一款,现在作者升级了 rtorrent-pro 付费 15 欧元。这又是一款 BT 下载工具,界面非常美观。
rtorrent development for QNAP was started in 2008. Today after 10yrs from its 1st build, we provide you best Torrent app ever. rtorrent is an high performance and extra featured bittorrent client combined with simple and elegant user interface. rtorrent differentiates itself from other implementations by transferring data directly between file pages mapped to memory by the mmap() function and the network stack. On high-bandwidth connections, it claims to be able to seed at 3 times the speed of the official client. We strive to make rtorrent the best torrent client you could ever want!
支持的 QNAP 型号
如果不确定自己的 QNAP 型号,登录后台运行 uname -m
输出 CPU 架构如果是上面提到的两个就是支持的。
安装非常简单,下载应用,在后台上传安装即可。安装后默认的用户名是:rtorrent
密码是:admin
.
重启,启动,暂停的使用:
/etc/init.d/rtorrent.sh [start|stop|restart]
在安装完毕之后,第一件事情就是更改密码。
用新密码登录进去之后进行配置,首先熟悉配置文件的地址。
配置文件地址:
vi /share/CACHEDEV1_DATA/.qpkg/rtorrent/etc/rtorrent.conf
需要注意的是如果之前安装过其他 BT 下载工具,比如 Transmission 之类,可能会造成端口冲突 (DHT 端口),需要手工调整一下端口设置。
rtorrent 用到的端口:
注意到该路径,rtorrent 相关的内容都安装在了该路径中。安装完毕之后 rtorrent 会在 Download 目录下创建名为 rtorrent
的文件夹,并且创建软链接 /share/Rdownload
,rtorrent 下载的内容都会在该目录中。
In stock QNAP applications, a default Download share is used to save downloaded data from the Internet. Download share location is always static and only on the first initiated disk volume. In the default configuration, Rtorrent also uses the Download network share.
可以自定义 Rtorrent 存储的路径,创建共享文件夹名为 Rdownload
,指定一块硬盘,当创建共享文件夹时,记得关闭 Rtorrent-Pro,创建成功后再启动。这样 rtorrent-Pro 就会使用新的路径。
Transmission 之前的文章 也提到过监控某个文件夹,一旦有文件新加进去自动下载。
rtorrent 同样可以实现,默认的配置已经有配置,如果想要更加详细的了解,可以参考这里
Schedule 的语法:
# Schedule syntax: id,start,interval,command call cmd every interval seconds
比如:
schedule = watch_directory_1,20,10,"load.start=/downloads/watched/*.torrent"
说明:
用简短的一句话来总结上面的配置含义就是,定义了一个定时器,名叫 watch_directory_1, rTorrent 启动后 20 秒开始,每隔 10 秒执行一次命令,这个命令是从给定的目录中加载 torrent 文件。
# Maximum and minimum number of peers to connect to per torrent.
# throttle.min_peers.normal.set = 40
# throttle.max_peers.normal.set = 100
# 最小允许的 peer
min_peers = 40
# 最大允许 peer
max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
# throttle.min_peers.seed.set = 25
# throttle.max_peers.seed.set = 60
min_peers_seed = 10
max_peers_seed = 50
# Maximum number of simultanious uploads per torrent.
# throttle.max_uploads.set = 30
# 最大同时上传数
max_uploads = 10
# Global upload and download rate in KiB. "0" for unlimited.
# throttle.global_up.max_rate.set_kb = 0
# throttle.global_down.max_rate.set_kb = 0
# 最大下载速度
download_rate = 1024
# 最大上传速度
upload_rate = 512
# tracker_numwant = -1
#trackers.numwant.set = -1
# Max mapped memory
# nb does not refer to physical memory
# max_memory_usage = 768M
pieces.memory.max.set = 1024M
# Max number of files to keep open simultaneously
# max_open_files = 65536
#network.max_open_files.set = 1024
# max_open_http = 48
#network.http.max_open.set = 48
# Default directory to save the downloaded torrents.
# directory.default.set = /share/Rdownload/downloads/
# 下载目录
directory = /share/Rdownload/downloads/
# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
# session.path.set = /share/Rdownload/session
# 下载历史,包括进度信息,DHT 节点缓存
session = /share/Rdownload/session
# Schedule syntax: id,start,interval,command call cmd every interval seconds,
# starting from start.
# An interval of zero calls the task once while a start of zero calls it immediately.
# Start and interval may optionally use a time format dd:hh:mm:ss
# e.g. to start a task every day at 18:00, use 18:00:00,24:00:00.
# Commands: stop_untied =, close_untied =, remove_untied =
# Stop, Close or Remove the torrents that are tied to filenames that have been deleted
# Watch a directory for new torrents, and stop those that have been
# deleted.
# 将 torrent 文件放到该目录自动下载
schedule = watch_directory,10,10,load_start=/share/Rdownload/watch/*.torrent
# 将 torrent 文件移走停止下载
#schedule = untied_directory,10,10,stop_untied=
# Close torrents when diskspace is low.
# 当硬盘空间不足停止所有下载
schedule = low_diskspace,5,60,close_low_diskspace=1000M
# Stop torrents when reaching upload ratio in percent, when also reaching
# total upload in bytes, or when reaching final upload ratio in percent
# Example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
# 在总上传量达到 200M 的情况下上传 / 下载率达到 200%,
# 或者在总上传量不足 200M 情况下上传 / 下载率达到 2000%, 则停止上传
#schedule = ratio,60,60,stop_on_ratio=200,200M,2000
#ratio.enable=
#ratio.min.set=500
#ratio.max.set=2000
#ratio.upload.set=200M
#method.set = group.seeding.ratio.command, d.close=
# Port range to use for listening.
# network.port_range.set = 6890-6999
# bt 监听端口
port_range = 42000-42000
# Start opening ports at a random position within the port range.
# network.port_random.set = no
# 是否随机从上面的端口中选择
port_random = no
# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
# pieces.hash.on_completion.set = yes
check_hash = yes
# Set whether the client should try to connect to UDP trackers.
# use_udp_trackers = yes
trackers.use_udp.set = yes
# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
# Remove a scheduled event
# schedule_remove = "ip_tick"
# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
# dht.mode.set = auto
dht = auto
# UDP port to use for DHT.
# DHT 的 UDP 端口
# dht_port = 6881
dht.port.set = 6882
# Enable peer exchange (for torrents not marked private)
#
# protocol.pex.set = yes
protocol.pex.set = yes
#peer_exchange = yes
# network.scgi.open_port = 127.0.0.1:5000
scgi_port = 127.0.0.1:19000
#scgi_local = /var/run/rtorrent-rpc.socket
network.xmlrpc.dialect.set = i8
#xmlrpc_dialect=i8
encoding_list = UTF-8
以上配置文件非全部,如果要应用到真实环境,请拷贝完整的配置,以上只作为演示和注释使用。
BT 下载的工具有很多,qBittorrent,Transmission,rtorrent, uTorrent,等等,非常多,wiki 有一张非常详细的对比图,在不同系统上都有着各自的最佳选择。对占用资源,下载效率的测试还没有来得及验证,等使用一段时间后再来更新吧。
记得启用之后可以使用 [[Transdroid]] Android 客户端来管理 rtorrent-pro. 可以从 Google Play Store 下载,或者从官网:
安装之后在设置中添加 Server,名字,服务器类型,IP,HOST NAME,User name, password 没啥好说,这里的用户名和密码和界面上的用户名和密码一致。
在高级设置中,记得将 Port Number 设置为 6009, 或者使用 Use SSL
的话,输入 6008.
详细的每一步指导看这里
默认 SSH 登录到 QNAP 的 login shell 可以通过 echo $SHELL
来查看到是
/bin/sh
默认的这个 bash 是 QNAP 自带的
/bin/sh --version
GNU bash, version 3.2.57(1)-release (x86_64-QNAP-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
也是一个相对比较简陋的版本,自动补全很难用,也没有语法高亮。所以想能不能把 QNAP 自带的 shell 换成日常使用的 ZSH,QNAP 本质上就是一个 Linux,所以理所当然的应该是可行的。
首先要要解决的问题是安装问题,普通的 Linux 发行版直接使用一行命令就可以完成,QNAP 可以使用 QNAP club 别人提供的版本,直接安装即可
wget https://cdn.qnapclub.eu/qpkg_artifacts/ZSH_5.7.0_x86_64/ZSH_5.7.0_x86_64.qpkg
sh ZSH_5.7.0_x86_64.qpkg
如果你参考过我之前的文章 你应该知道添加了 QNAP Club 的地址可以直接在 App Center 中直接搜索下载。
安装好之后,默认的 zsh 会安装到
/opt/ZSH
SSH 登陆 QNAP 之后直接在终端输入 zsh
即可进入 zsh。
ZSH 一些强大的功能:
默认的配置在 /opt/ZSH
中,可以自己做一些微调,比如
vi /opt/ZSH/zshrc.zsh-template
or
vi /root/.zshrc
修改主题
ZSH_THEME="agnoster"
等等。
如果在使用过程中发现,delete功能异常,比如delete虽然删除了字符但是向右多显示一个空格,而且不显示移动光标 那么可以编辑zsh配置文件
vi ~/.zshrc
在.zshrc里添加
TERM=xterm
保存, 然后执行, 使配置生效
source ~/.zshrc
很早就开始用 Cinnamon 作为 Linux 的主要桌面环境,还折腾过 Cinnamon 的主题,但是其实一直没怎么关注 Alt + F2 的功能,唯一知道的命令就是 r
用来重启 Cinnamon。所以这里就总结总结 Alt+F2 可以用的命令。
-‘r’ - restart Cinnamon
在 Alt + F2 下运行无界面的命令,比如 ls
可能得不到任何结果,但是可以运行比如 firefox
这样有窗口的命令。该命令需要在 PATH 下。
在 Alt + F2 窗口下输入文件目录可以快速使用默认文件浏览器打开该目录。
这篇文章主要讲解如何在项目中执行 DRL 文件并取得结果。
如果遇到这样的错误,大部分情况下是 drl 规则文件所在的文件夹,没有被项目识别为 resources
文件夹,在 IntelliJ IDE 中可以使用设置为资源文件夹
来解决。
Exception in thread "main" java.lang.RuntimeException: Unable to get LastModified for ClasspathResource
at org.drools.core.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:212)
at org.drools.core.io.impl.ClassPathResource.getInputStream(ClassPathResource.java:149)
at org.drools.compiler.compiler.DrlParser.parse(DrlParser.java:154)
at org.drools.compiler.compiler.DrlParser.parse(DrlParser.java:144)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.drlToPackageDescr(KnowledgeBuilderImpl.java:541)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDrl(KnowledgeBuilderImpl.java:529)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addKnowledgeResource(KnowledgeBuilderImpl.java:753)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:2296)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:2285)
at com.neo.drools.banking.RuleRunner.runRules(RuleRunner.java:32)
at com.neo.drools.banking.BankingExample1.main(BankingExample1.java:10)
Caused by: java.io.FileNotFoundException: 'Example1.drl' cannot be opened because it does not exist
at org.drools.core.io.impl.ClassPathResource.getURL(ClassPathResource.java:173)
at org.drools.core.io.impl.ClassPathResource.getLastModified(ClassPathResource.java:185)
... 10 more