LoginSignup
1
0

More than 3 years have passed since last update.

OpenWrtにWebmin

Last updated at Posted at 2021-03-22

OpenWrtにWebmin

その必要性はともかく、OpenWrtにWebminを入れてみようかと思いました。

参考:
https://wiki.terrabase.info/wiki/Webmin_on_Entware_for_DD-WRT
https://wiki.terrabase.info/wiki/Linksys_AC_Series_Router_Configuration_Tips_for_OpenWRT
https://www.webmin.com/tgz.html

インストールの準備

OpenWrtベース環境

KVM上のx86_64版のOpenWrt仮想マシンに入れました。試したバージョンは19.07.6です。

元のイメージファイル(raw)が300MB弱くらい、インストール時のワークで+300MB強、
さらにインストールイメージ+perlで+300MB強必要になりました。
で、私はイメージファイルを1Gに拡張してやりました。

OpenWrt(raw)イメージファイルの拡張
    # mv openwrt.img openwrt.img_org
    # qemu-img create -f raw openwrt.img 1G
    # virt-resize --expand /dev/sda2 openwrt.img_org openwrt.img

参考:https://docs.openstack.org/ja/image-guide/modify-images.html

BusyBox更新

BusyBoxを公式の最新版にしました。
OpenWrt標準のdfコマンドだとオプション-iが使えず起動時にワーニングがでるため。
(多分、無視していいと思うけど)

BusyBoxのダウンロード(私がやったときはこれが最新)
https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64

ダウンロードしたバイナリを/binにコピーして、シンボリックリンクにしてみました。
インストール時にhostnameコマンドが必要とされますので、ln -sしておきます。

BusyBoxのインストール
    # cd /bin
    # mv $HOME/busybox-x86_64 /bin/busybox-x86_64
    # mv busybox busybox_org
    # busybox_org ln -s busybox-x86_64 busybox
    # ln -s busybox hostname
binグループの追加
    # vi /etc/group
        root:x:0:
        daemon:x:1:
        bin:x:2:            # binグループを追加
        adm:x:4:
        :
    :wq!
    #
logディレクトリの追加
    # mkdir -p /opt/local/webmin/log    # どこでもいい

ログ出力先は/var/log/webminでもよかったんだけど、
/varは/tmpにリンクされてて、再起動すると消えるので、/optにしました。

インストール

Webminのtar fileのダウンロード(私がやったときはこれが最新)
https://sourceforge.net/projects/webadmin/files/webmin/1.973/webmin-1.973.tar.gz/download

rootのホームディレクトリで作業することとしました。
モジュールのインストール先を指定してsetup.shを実行します。

Webminインストール
    # tar zxvf webmin-1.973-minimal.tar.gz      # 展開
    # cd webmin-1.973/
    # ./setup.sh /opt/local/webmin/modules      # インストール先を指定して実行
    ***********************************************************************
    *          Welcome to the Webmin setup script, version 1.973          *
    ***********************************************************************
    Webmin is a web-based interface that allows Unix-like operating
    systems and common Unix services to be easily administered.

    Installing Webmin from /root/webmin-1.973 to /opt/local/webmin/modules ...

    ***********************************************************************
    Webmin uses separate directories for configuration files and log files.
    Unless you want to run multiple versions of Webmin at the same time
    you can just accept the defaults.

->  Config file directory [/etc/webmin]:            # デフォルトにしました
->  Log file directory [/var/webmin]: /opt/local/webmin/log     # ログ出力先
    ***********************************************************************
    Webmin is written entirely in Perl. Please enter the full path to the
    Perl 5 interpreter on your system.

->  Full path to perl (default /usr/bin/perl):      # デフォルトで良いはず

    Testing Perl ...
    Perl seems to be installed ok

    ***********************************************************************
    For Webmin to work properly, it needs to know which operating system
    type and version you are running. Please select your system type by
    entering the number next to it from the list below
    ---------------------------------------------------------------------------
      1) Pardus Linux           2) SmartOS                3) Sun Solaris          
      4) Lycoris Desktop/LX     5) Caldera OpenLinux eS   6) Caldera OpenLinux    
      7) Asianux Server         8) Asianux                9) Whitebox Linux       
        :
     106) OS X                  107) Mac OS X              108) Darwin               
     109) OpenDarwin            110) Cygwin                111) Sun Java Desktop Sys 
     112) Synology DSM          113) Generic Linux         114) Windows              
    ---------------------------------------------------------------------------
->  Operating system: 113       #(113.汎用Linuxを指定)

    Please enter the version of Generic Linux you are running
->  Version: *.**               #(適当)

    Operating system name:    Generic Linux
    Operating system version: *.**

    ***********************************************************************
    Webmin uses its own password protected web server to provide access
    to the administration programs. The setup script needs to know :
     - What port to run the web server on. There must not be another
       web server already using this port.
     - The login name required to access the web server.
     - The password required to access the web server.
     - If the webserver should use SSL (if your system supports it).
     - Whether to start webmin at boot time.

->  Web server port (default 10000):    # 変えたければ適当に
->  Login name (default admin):         # 変えたければ適当に
->  Login password: ************        # パスワードは適当に
->  Password again: ************        # パスワードは適当に
    The Perl SSLeay library is not installed. SSL not available.
->  Start Webmin at boot time (y/n): n  # 自動起動は別に設定するよ
    ***********************************************************************
    Copying files to /opt/local/webmin/modules ..
    ..done

    Creating web server config files..
    ..done
        :
    Enabling background status collection ..
    ..done

    Attempting to start Webmin mini web server..
    Starting Webmin server in /opt/local/webmin/modules
    ..done

    ***********************************************************************
    Webmin has been installed and started successfully. Use your web
    browser to go to

      http://kamosan:10000/

    and login with the name and password you entered previously.
    #

エラーが出なければ、これで起動しているはず。

起動の確認
    # vi /etc/rc.local
    # ps aux | grep miniserv
        11222 root      0:00 {miniserv.pl} /usr/bin/perl /opt/local/webmin/modules/miniserv.pl /etc/webmin/miniserv.conf
        11231 root      0:00 grep miniserv
    #
エラーログの確認
    # cat /opt/local/webmin/log/miniserv.error
        [22/Mar/2021:22:34:17 +0900] miniserv.pl started
        [22/Mar/2021:22:34:17 +0900] IPv6 support cannot be enabled without the Socket6 perl module
        [22/Mar/2021:22:34:17 +0900] Using MD5 module Digest::MD5
        [22/Mar/2021:22:34:17 +0900] Using SHA512 module Crypt::SHA
    #

自動起動の設定

ローカルスタートアップの設定
    # vi /etc/rc.local
        :
        /etc/webmin/start   # startの追加
        exit 0
    :wq!
    #

動作確認

ブラウザから、

    http://kamosan:10000/

ログイン画面が出るのでログインして。
エラーログを確認。
この手順通りだと「webmin-lib.pl line 1133」でエラーはでるみたい。
それ以外のエラーが出なければOK。

エラーログの確認
    # cat /opt/local/webmin/log/miniserv.error
        [22/Mar/2021:22:34:17 +0900] miniserv.pl started
        [22/Mar/2021:22:34:17 +0900] IPv6 support cannot be enabled without the Socket6 perl module
        [22/Mar/2021:22:34:17 +0900] Using MD5 module Digest::MD5
        [22/Mar/2021:22:34:17 +0900] Using SHA512 module Crypt::SHA
        Use of uninitialized value in string ne at /opt/local/webmin/modules/webmin/webmin-lib.pl line 1133.
    #

エラー対応など後日追加

1133エラーを出ないようにする。
    # vi /opt/local/webmin/modules/os_list.txt
        :
        # All other Linux variants, identified by kernel version                                                                                                               
        Generic Linux                   $1      generic-linux   $1      `uname -r` =~ /^([0-9]+\.[0-9+])\./                                                                    
        # (次行追加、バージョン2セグメントが複数桁でもOKにするだけ)
        Generic Linux                   $1      generic-linux   $1      `uname -r` =~ /^([0-9]+\.[0-9+]+)\./ 
        :
「ローカルディスクのパーティション」でfdiskコマンドが求められる
    # cd /bin
    # ln -s busybox fdisk
    # ln -s busybox hdparm

私の環境(?)ではパーティションテーブルが正しく読めてないので、
パーティションの操作はためしてません。

アンインストール

最初からやり直したいときは。

アンインストール
    # /etc/webmin/stop
    # /etc/webmin/uninstall.sh
    # rm -rf /opt/local/webmin/log
    # vi /etc/rc.local
        :
        # /etc/webmin/start # startのコメントアウト
        exit 0
    :wq!
    #

どや

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0