liujia 发布的文章

在 FreeBSD 13.2 里尝试安装 iRedMail 1.6.8 - 放弃

原因:看到 iRedMail 群里有人说在 FreeBSD 13.2 里安装出错,提示如:

lsof-4.99.3_1,8 requires kernel sources.
error code 1
stop.
make stopped in /usr/ports/sysutils/lsof
error code 1
stop
make stooped to /usr/ports/devel/py-Jinjia2
error failed to downloading package, please fix it manually and then relaunch iRedMail installer.

我在一台国外的机子,配置是 Atom C2750, 8GB 内存里测试 iRedMail 的安装。遇到同样的报错信息。虽然可以手工下载 ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/13.2-RELEASE/src.txz 后继续安装,但通过 ports 编译软件,所需的时间太长了。过了约24小时,还没完成,当前界面信息停留在:

l' -Cprefer-dynamic -Z binary-dep-depinfo -L native=/usr/ports/lang/rust/work/_build/x86_64-unknown-freebsd/stage0-rustc/x86_64-unknown-freebsd/release/build/psm-d1aad399e5dbb6f5/out -L native=/usr/ports/lang/rust/work/_build/x86_64-unknown-freebsd/stage0-rustc/x86_64-unknown-freebsd/release/build/rustc_llvm-938455d976a8c95f/out -L native=/usr/ports/lang/rust/work/_build/x86_64-unknown-freebsd/llvm/build/lib`
    Building [=======================> ] 316/323: rustc_driver_impl

但我不想等待结果,放弃了。

-- Build files have been written to: /usr/ports/lang/rust/work/_build/x86_64-unknown-freebsd/lld/build
running: cd "/usr/ports/lang/rust/work/_build/x86_64-unknown-freebsd/lld/build" && DESTDIR="" "cmake" "--build" "." "--target" "install" "--config" "Release" "--" "-j" "1"
[  1% 3/127] Building CXX object Common/CMakeFiles/lldCommon.dir/CommonLinkerContext.cpp.o^C
ninja: build stopped: interrupted by user.

Build completed unsuccessfully in 14:46:49
*** Error code 1
*** Signal 2

参考:

在已有Debian系统的硬盘里安装 FreeBSD 13.2

需求:硬盘原先已经有Windows,debian 12 系统了,现在想在一个分区里再安装个 FreeBSD 13.2。

步骤:

  1. 将机子从rescue系统启动,以qemu虚拟机的方式,从 https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-amd64-bootonly.iso 开始往硬盘的第4个分区里安装 FreeBSD
  2. 安装过程中,勾选 sshd ,且在 /etc/rc.conf 里添加静态IP的配置内容,如:

    ifconfig_igb0="inet 144.172.126.97 netmask 255.255.255.0"
    ifconfig_igb1="inet 144.172.126.97 netmask 255.255.255.0"
    defaultrouter="144.172.126.1"
  3. FreeBSD安装结束后,将机子从 Debian 12 系统启动,手工修改 /boot/grub/grub.cfg 启动菜单内容,添加如:

    menuentry "FreeBSD 13.2" {
    insmod ufs2
    set root=(hd0,4)
    kfreebsd /boot/loader
    }
  4. 执行如 grub-reboot 4 && reboot 的命令,就可以单次尝试从grub里引导 FreeBSD 系统了
  5. gpart show 的输出信息:

    root@dr3:~ # gpart show
    =>        63  3907029105  ada0  MBR  (1.8T)
          63        1985        - free -  (993K)
        2048   419430400     1  ntfs  (200G)
    419432448  3221225472     2  linux-data  (1.5T)
     3640657920   104857600     3  ntfs  (50G)
     3745515520   161480704     4  freebsd  [active]  (77G)
     3906996224       32944        - free -  (16M)
    
    =>        0  161480704  ada0s4  BSD  (77G)
          0  153092096       1  freebsd-ufs  (73G)
     153092096    8073216       2  freebsd-swap  (3.8G)
     161165312     315392          - free -  (154M)

参考:

在 debian 12 里安装 request tracker 5

假设:RT5的访问网址是 https://rt.demo.anqun.org ,“售后”队列的收件箱是 support@rt.demo.anqun.org ,搭配 apache 与 mariadb 数据库。

步骤:

  1. hostnamectl set-hostname rt.demo.anqun.org # 设置好主机名
  2. apt update # 更新软件源
  3. apt install mariadb-server # 先安装数据库
  4. systemctl start mariadb # 启动数据库
  5. apt install apache2 rt5-db-mysql rt5-apache2 rt5-fcgi request-tracker5 # 安装RT5,如果提示输入RT的实例名称,我这里是填写了完整的主机名 rt.demo.anqun.org,还会提示设置RT使用的数据库密码和默认用户root的密码
  6. a2dismod mpm_event
  7. a2enmod mpm_prefork # 切换apache的运行模块
  8. a2enmod ssl # 启用https访问
  9. /etc/request-tracker5/RT_SiteConfig.d/50-debconf.pm # 修改配置文件中的 $WebPath 为空,因为本例是访问到/路径
  10. /etc/apache2/sites-enabled/rt.conf # RT的站点设置内容,如下:

    <VirtualHost *:443>
        ### Optional apache logs for RT
        # Ensure that your log rotation scripts know about these files
        # ErrorLog /opt/rt5/var/log/apache2.error
        # TransferLog /opt/rt5/var/log/apache2.access
        # LogLevel debug
        ServerName rt.demo.anqun.org
    
    SSLEngine on
    SSLCertificateFile  /root/.acme.sh/rt.demo.anqun.org_ecc/rt.demo.anqun.org.cer
    SSLCertificateKeyFile /root/.acme.sh/rt.demo.anqun.org_ecc/rt.demo.anqun.org.key
    SSLCertificateChainFile  /root/.acme.sh/rt.demo.anqun.org_ecc/ca.cer
    
        AddDefaultCharset UTF-8
        FcgidInitialEnv RT_SITE_CONFIG /etc/request-tracker5/RT_SiteConfig.pm
    # The defaults are unlikely to be big enough for an RT site handling
    # attachments
        FcgidMaxRequestLen 1073741824
    #        ScriptAlias / /opt/rt5/sbin/rt-server.fcgi/
    # Use the handler
    # Note: If you switch the configuration to be served up from / use a
    # trailing / - ie:
    #   ScriptAlias / /usr/share/request-tracker5/libexec/rt-server.fcgi/
    ScriptAlias / /usr/share/request-tracker5/libexec/rt-server.fcgi/
    
        DocumentRoot "/usr/share/request-tracker5/html"
    
    # Alias "/static" "/usr/share/request-tracker5/static"
    <Location />
    DirectoryIndex index.html
    #            Require all granted
    #            Options +ExecCGI
    #            AddHandler fcgid-script fcgi
    </Location>
    
    # Limit mail gateway access to localhost by default
    <Location /REST/1.0/NoAuth>
    <IfVersion >= 2.3>
        Require local
    </IfVersion>
    <IfVersion < 2.3>
        Order Allow,Deny
        Allow from 127.0.0.1
    </IfVersion>
    </Location>
    </VirtualHost>
  11. systemctl restart apache2 # 重启apache服务后,看看能否访问到RT的web页面。如果root能成功登录,请创建“售后”的队列,且设置收件箱为support。简化测试,让everyone可以有创建和回复工单的权限
  12. dpkg-reconfigure exim4-config # 配置 exim4 ,关键是填写收件箱的域,如 rt.demo.anqun.org 和监听的网络接口(本例是留空,表示在所有的网络接口里监听25端口)
  13. /etc/exim4/conf.d/router/050_exim4-config_rt5support # 创建收件箱地址的router,内容如下:

    rt5support_router:
    driver = accept
    local_parts = support
    transport = rt5support_transport
    
    rt5supportcomment_router:
    driver = accept
    local_parts = support-comment
    transport = rt5supportcomment_transport
  14. /etc/exim4/conf.d/transport/50_exim4-config_rt5support_pipe # 创建收件箱的pipe,内容如下:

    rt5support_transport:
     driver = pipe
     command = "/usr/bin/rt-mailgate --queue 售后 --action correspond --url https://rt.demo.anqun.org"
    
    rt5supportcomment_transport:
     driver = pipe
     command = "/usr/bin/rt-mailgate --queue 售后 --action comment --url https://rt.demo.anqun.org"
  15. update-exim4.conf.template -r && update-exim4.conf && systemctl reload exim4 # 将exim4的配置更新
  16. 如果顺利,发往suuport@rt.demo.anqun.org的邮件,会自动出现在“售后”队列中,从web里可以查看到

参考:

hMailServer - 批量创建用户 - vbs脚本

需求:通过csv文件,能批量导入邮箱地址和密码,如

chen10,nfhe7384,hmail2.demo.anqun.org
chen11,nfhe755t,hmail2.demo.anqun.org
chen12,nfhe755t,hmail3.demo.anqun.org

尝试:通过hMailServer的COM API,用vbs脚本可从csv文件读取邮箱用户、密码和域名。

脚本内容:

'#####the script#####
'# The EntryType can be one of two options, User or Alias. If the EntryType is User, then:
'#
'# EntryType = User
'# Field1 = Uername
'# Field2 = Password
'# Field3 = DomainName
'# Field4 = FirstName
'# Field5 = LastName
'#
'# If the EntryType is Alias, then:
'# EntryType = Alias
'# Field1 = AliasName
'# Field2 = ForwardingEmail
'# Field3 = DomainName
'#
'# To add USERS, for example, your CSV file should have the structured information (type, strUsername, strPassword, strDomain, strPersonFirstName, strPersonLastName), like below:
'# User,tjones,mypassword,jones.com,Tommy,Jones
'#
'# To add ALIAS, for example, your CSV file should have the structured information (type, strAlias, strAliasUsername, strDomain), like below:
'# Alias,tommy,tjones@jones.com,jones.com
'#
'# This would create a user names tjones@jones.com in the jones.com domain and an alias tommy@jones.com which will forward all e-mail to tjones@jones.com in the jones.com domain.
'####################

Option Explicit
Dim Elog
Dim obBaseApp
Dim objFSO
Dim objTextFile
Dim strNewAlias,i

Dim failed
Dim added
Dim domainsAdded

failed = 0
added = 0
domainsAdded = 0

'#####################################################################
'# Custom Variables regarding HMAIL admin password and file to be read
'#####################################################################
Dim hAdminpwd
Dim CSVFile
hAdminpwd = "hmailmima"
CSVFile = "bulk.csv"

Set Elog = CreateObject("hMailServer.EventLog")
Set obBaseApp = CreateObject("hMailServer.Application")

Call obBaseApp.Authenticate("Administrator",hAdminpwd) '*** N.B. 1. set your administrator password in this line

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(CSVFile, ForReading) 'N.B. 2. Set your CSV path/filename in this line
On Error resume next
Do While objTextFile.AtEndOfStream <> True
    strNewAlias = split(objTextFile.Readline, ",")

    'Select Case lcase(trim(strNewAlias(0)))
       'Case "user"
          ' AddUser trim(strNewAlias(1)), trim(strNewAlias(2)), trim(strNewAlias(3)),trim(strNewAlias(4)),trim(strNewAlias(5))
       'Case "alias"
          'AddAlias trim(strNewAlias(1)), trim(strNewAlias(2)), trim(strNewAlias(3))
    'End Select
    
    AddUser trim(strNewAlias(0)), trim(strNewAlias(1)), trim(strNewAlias(2))
    
    If err.Number <> 0 Then    'error handling:
     Elog.Write("Failed add (probably duplicate)" & Chr(34) & vbTab & Chr(34) & strNewAlias(0) _
     & "," & strNewAlias(1) & "," & strNewAlias(2) & "," & strNewAlias(3))
     failed = failed + 1
     err.Clear
    Else
     added = added + 1
    End If
Loop
On Error goto 0
Elog.Write("Domains Added Sucessfully    = " & domainsAdded)
Elog.Write("Accounts Added Sucessfully   = " & added)
Elog.Write("Failed or Duplicate Accounts = " & failed)
Wscript.Echo ("Domains Added Sucessfully    = " & domainsAdded & VbNewLine _
            & "Accounts Added Sucessfully   = " & added & VbNewLine _
            & "Failed or Duplicate Accounts  = " & failed & VbNewLine & VbNewLine _
            & "See hmailserver_events.log for list of duplicates (if any)")

'###################
'# Usefull functions
'###################
Sub AddAlias(strAlias,strEmailAddress,strDomain)

   AddDomain strDomain

   Dim obDomain
   Dim obAliases
   Dim obNewAlias

   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obAliases = obDomain.Aliases
   Set obNewAlias = obAliases.Add()
   
   obNewAlias.Name = strAlias & "@" & strDomain 'username
   obNewAlias.Value = strEmailAddress 'password
   obNewAlias.Active = 1 'activates user
   obNewAlias.Save() 'saves account
   
   Set obNewAlias = Nothing
   Set obAliases = Nothing
   Set obDomain = Nothing
   
End Sub

'Sub AddUser(strUsername, strPassword, strDomain, strPersonFirstName, strPersonLastName)
Sub AddUser(strUsername, strPassword, strDomain)
   
   AddDomain strDomain
   
   Dim obDomain
   Dim obAccounts
   Dim obNewAccount

   Set obDomain = obBaseApp.Domains.ItemByName(strDomain)
   Set obAccounts = obDomain.Accounts
   Set obNewAccount = obAccounts.Add()
   
   obNewAccount.Address = strUsername & "@" & strDomain 'username
   obNewAccount.Password = strPassword 'password
   'obNewAccount.PersonFirstName = strPersonFirstName
   'obNewAccount.PersonLastName = strPersonLastName
   obNewAccount.Active = 1 'activates user
   obNewAccount.Maxsize = 0 'sets mailbox size, 0=unlimited
   obNewAccount.Save() 'saves account
 
   Set obNewAccount = Nothing
   Set obDomain = Nothing   
   Set obAccounts = Nothing
 
End Sub

Sub AddDomain(strDomain)
   Dim obNewDomain
   Set obNewDomain = obBaseApp.Domains.Add()
   obNewDomain.Name = strDomain
   obNewDomain.Active = True

   On Error resume next
   obNewDomain.Save()
   If err.Number = 0 Then
    domainsAdded = domainsAdded + 1
   End If
   err.Clear
 
   obBaseApp.Domains.Refresh()
End Sub

参考:

Windows 2012 R2 无法安装 .NET Framework 3.5 - .NET Framework 2.0 - KB5029915

现象:Windows 2012 R2 系统,无法通过“服务器管理器”和DISM命令安装.NET Framework 3.5,即使指定SxS安装源路径,一样报错。

尝试:查看已安装的Windows更新,检索其中与 .NET Framework 3.5 的更新。删除其中的 KB5029915 后,即可安装 .NET Framework 3.5。原因可能是当 Windows 2012 R2没有安装 .NET Framework 3.5 组件时进行了Windows Update,安装.NET Framework 3.5 的安全更新后,导致不能正常安装 .NET Framework 3.5。

参考: