分类目录归档:日志

Manjaro中VMwareWorkstation网卡无法连接的解决办法

提示信息可能像这样:

Could not connect 'Ethernet0' to virtual network '/dev/vmnet0'. More information can be found in the vmware.log file.

Failed to connect virtual device 'Ethernet0'.

尝试以下操作:

  1. 启动网络服务
sudo systemctl restart vmware-networks
  1. 尝试重装内核
# 61 改为自己的版本
yay -S linux61 linux61-headers

重启后再试。

  1. 重置网卡设置
sudo touch /etc/vmware/x && sudo vmware-networks --migrate-network-settings /etc/vmware/x && sudo rm /etc/vmware/x && sudo modprobe vmnet && sudo vmware-networks --start

参考:

  1. https://www.jianshu.com/p/d01e65ea8d09
  2. https://communities.vmware.com/t5/VMware-Workstation-Pro/Network-services-failed-in-Linux-installation-VMware-workstation/td-p/2317431

php 框架执行存储过程(stored procedure) 并获取返回

laravel

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use PDO;

class TestController extends Controller
{
    public function index()
    {
        $pdo = DB::getPdo();
        $int = 1;
        $res = 0;
        $stmt = $pdo->prepare("EXEC dbo.test :int,:res");
        $stmt->bindParam(':int', $res, PDO::PARAM_INT);
        $stmt->bindParam(':res', $res, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 400);
        $stmt->execute();
        dd($res);
    }
}

参考:

  • https://stackoverflow.com/questions/71321858/api-laravel-call-store-procedure-with-in-and-out-parameter-using-oci8-or-pdo
  • https://laracasts.com/discuss/channels/general-discussion/running-stored-procedures

thinkphp 5.0

tp5 需要修改原码才可以使用:

  • 找到文件 thinkphp/library/think/db/Connection.php
  • 第 388 行,在 catch (\PDOException $e) 内,修改为如下代码:
    if ($procedure == true) { return; } elseif ($this->isBreak($e)) { return $this->close()->query($sql, $bind, $master, $pdo); }

控制器执行:

<?php

namespace app\api\controller;

use PDO;
use think\Db;

class Test extends Common {
    public function index() {
        $int = 1;
        $res = 1;
        Db::query('exec test :int,:res', [
            'int' => $int,
            'res' => [&$res, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 4000],
        ]);
        print_r($res);
    }
}

参考:

  • https://blog.csdn.net/Drug_/article/details/95474776

以上示例使用的存储过程如下:

ALTER PROC [dbo].[test]
-- 创建:CREATE PROC [dbo].[test]
 @IntInput int,
 @StrResult varchar(20) out
as
begin
         if (@IntInput>1)
           Set
        @StrResult = '>1'
        else 
            Set
        @StrResult = '<=1'
end

SQL 执行:

declare @strResult varchar(20)
exec test -1,@strResult output
print @strResult

nextcloud配置

商店代理

配置目录:config/config.php ,在配置数组中添加以下项:

 'installed' => true, # 原有配置项
'appstoreenabled' => true,
# 以下二选一
'appstoreurl' => 'https://www.orcy.net/ncapps/v1/', # 仅加速目录列表
'appstoreurl' => 'https://www.orcy.net/ncapps/v2/', # 加速github,推荐

删除目录缓存:data/appdata_<xxx>/appstore/apps.json

安装应用

  • Office & text
    • Plain text editor
继续阅读

svn 迁移到 git

用户迁移配置 userinfo.txt

svn_user = git_user <git_user_email>
svn_user2 = git_user2 <git_user_email2>

迁移项目

git svn clone <https://server/svn/xx> --username <user> [--password <password>] --prefix=svn/ --no-metadata --authors-file=<userinfo.txt> --stdlayout

如果出现 Author: VisualSVN Server not defined in userinfo.txt file ,应当在 userinfo.txt 中添加缺失的用户。

如果出现 Can't locate Term/ReadKey.pm in @INC ,执行以下命令(以 manjaro 系统为例):

yay -S perl-term-readkey

linux 系统清理日志 /var/log/journal

1、用echo命令,将空字符串内容重定向到指定文件中

echo "" > system.journal

说明:此方法只会清空一次,一段时间后还要再次手动清空很麻烦,这里可以用以下命令让journalctl 自动维护空间

2、journalctl 命令自动维护文件大小

1)只保留近一周的日志

journalctl --vacuum-time=1w

2)只保留500MB的日志

journalctl --vacuum-size=500M

3)直接删除 /var/log/journal/ 目录下的日志文件

rm -rf /var/log/journal/<folder>

群晖NAS接入WireGuard

  • 编译
git clone https://github.com/runfalk/synology-wireguard.git
cd synology-wireguard/
sudo docker build -t synobuild .
sudo docker run --rm --privileged --env PACKAGE_ARCH=apollolake --env DSM_VER=6.2 -v $(pwd)/artifacts:/result_spk synobuild

注意:

  • 在 artifacts 文件夹内找到 WireGuard-*.spk,在 群晖中的 Package Center 里手动安装
  • ssh连接到NAS,创建 /etc/wireguard/wg0.conf
[Interface]
PrivateKey = 123456789
Address = 10.8.0.2/24
#DNS = 114.114.114.114   <-- 注意:DNS 这行整个删除
PostUp = ping -c 1 10.8.0.1; sleep 5; ip route add 10.8.0.0/24 dev wg0  <-- 关键:添加这一行

[Peer]
PublicKey = 123456789
PresharedKey = 123456789
AllowedIPs = 10.8.0.0/24
Endpoint = ip:51820

除特别注明的两行外,其他按原配置不要修改,除非你知道你在做什么。

  • 执行以下命令
sudo /var/packages/WireGuard/scripts/start
wg-quick up wg0
wg-autostart enable wg0