LoginSignup
0
0

OpenWrt GUI webmin

Last updated at Posted at 2024-04-27

:warning:Japanese notation

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • UCIとLuCi及びWinSCPにて比較しながら作業がおススメ

PowerShellSSHアクセス

ssh root@192.168.1.1
ssh root@192.168.1.1のショートカット作成(デスクトップ)
powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

  • 強制的に貼り付け
  • yes

SSHログイン出来ない場合:exclamation:

known_hostsクリア

  • C:\Users\yourusername\.ssh\known_hosts ※Windows隠しファイル
powershell
Clear-Content .ssh\known_hosts -Force


OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載

  • 機能の確認
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


webmin

前提条件

  • フラッシュ容量350MB以上(Google Wifi、ncp-hg100等おすすめ)
  • 動作確認バージョン:webmin 2.110
  • 動作確認デバイス : BPI-R3/ NCP-HG100
  • 動作確認クライアント:Windows11

インフォメーション

Dashboard.png

Perlインストール

opkg update && opkg install tar gzip unzip shared-mime-info openssl-util coreutils coreutils-install coreutils-stty coreutils-df make gawk fdisk patch diffutils
opkg list | grep perlbase-| awk '{print $1}' | xargs opkg install
opkg install perl-test-warn
opkg install perl-test-harness --force-overwrite

webminインストール

※インストールディレクトリ(DIR)及びログファイルディレクトリ(LOG):任意

DIR="/usr/libexec/webmin" # インストールディレクトリ
LOG="/lib/webmin" # ログファイルディレクトリ ※/var(=tmp)以外
sed -i "/bin:x:2:/d" /etc/group
echo bin:x:2: >> /etc/group
mkdir -p ${LOG}
wget --no-check-certificate -O /tmp/webmin.tar.gz https://www.webmin.com/download/webmin-current.tar.gz
mkdir -p ${DIR} && tar xzvf /tmp/webmin.tar.gz -C ${DIR} --strip-components 1
sed -i -e "s@/var/webmin@${LOG}@g" ${DIR}/setup.sh
sed -i -e "s/atboot=1/atboot=0/g" ${DIR}/setup.sh # xinetd利用時コメントアウト
sed -i "/makeboot=1/d" ${DIR}/setup.sh # xinetd利用時コメントアウト
RANDA8="head /dev/urandom | env LC_CTYPE=C tr -dc 'A-Za-z0-9'| cut -b -8"
RANDA2="head /dev/urandom | env LC_CTYPE=C tr -dc 'A-Za-z0-9'| cut -b -2"
RANDB8="tr -dc A-Za-z0-9 </dev/urandom | head -c 8"
RANDB2="tr -dc A-Za-z0-9 </dev/urandom | head -c 2"
sed -i -e "s@${RANDB8}@${RANDA8}@g" ${DIR}/setup.sh
sed -i -e "s@${RANDB2}@${RANDA2}@g" ${DIR}/setup.sh
${DIR}/setup.sh ${DIR}

設定値入力

※ユーザー名、パスワードなど、ログイン後変更可
太字は入力必須

  • Config file directory [/etc/webmin]:
  • Log file directory [/var/webmin /lib/webmin/]: インストール時設定変更済 :warning:
  • Full path to perl (default /usr/bin/perl):
  • Operating system: Generic Linux :warning:
  • Please enter the version of Generic Linux you are running Version: 例:5.15.150 :warning:
  • 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) インストール時設定変更済 :warning:
  • Webmin has been installed and started successfully.

サービス修正

#! /bin/sh
/etc/webmin/stop
cp /etc/init.d/webmin /etc/init.d/webmin.old
chmod 644 /etc/init.d/webmin.old
sed -i "/session=1/d" /etc/webmin/miniserv.conf
SERV=`grep 'port=' /etc/webmin/miniserv.conf | cut -d'=' -f2`
echo -e "webmin\t\t${SERV}/tcp" >> /etc/services
cat << "EOS" | sed -i '/END INIT INFO/r /dev/stdin' /etc/init.d/webmin

START=98
STOP=01
EOS
cat << 'EOS' | sed -i '/case/r /dev/stdin' /etc/init.d/webmin
boot)
        $START
        RETVAL=$?
        if [ "$RETVAL" = "0" ]; then
                touch $LOCKFILE >/dev/null 2>&1
        fi
        ;;
EOS


service webmin enable
service webmin start

サービス

  • 確認
service webmin status

  • 開始及び停止
# 有効
service webmin enable
# 開始
service webmin start
# 停止
service webmin stop
# 無効
service webmin disable

起動

  • 192.168.1.1:10000 ※初期値ポート
    ログイン
     ユーザー: admin ※設定したユーザー
     パスワード:

日本語化

webmin.png

既知の問題

インストール

  • 修正済み
    以下のエラーが出る
Creating web server config files ..
tr: write error: Broken pipe
tr: write error: Broken pipe
.. done

サービス

  • inetd=1を書くとリロードしなくなる
    (テーマ、パスワード設定などリロードしない、リスタートで正常化)
echo inetd=1 >> /etc/webmin/miniserv.conf

  • inetd=1を書かないとリロードするが、まれにエラーを吐き出す(他正常)
    エラー: 404 File not found - /stats.cgi?xhr- stats=general
sed -i "/inetd=1/d" /etc/webmin/miniserv.conf

Perlモジュールインストール

Net::SSLeayインストール不可の為、SSL暗号化及びwebminアップグレード利用不可

compile.png

CPANの使用
CPAN-DistnameInfo-0.12

wget --no-check-certificate -O /tmp/CPAN-DistnameInfo-0.12.tar.gz https://cpan.metacpan.org/authors/id/G/GB/GBARR/CPAN-DistnameInfo-0.12.tar.gz
mkdir -p /tmp/CPAN-DistnameInfo && tar xzvf /tmp/CPAN-DistnameInfo-0.12.tar.gz -C /tmp/CPAN-DistnameInfo --strip-components 1
(cd /tmp/CPAN-DistnameInfo && perl Makefile.PL && make && make install) 
mkdir -p /tmp/perl_cash
HOME=/tmp/perl_cash perl -MCPAN -e shell
  • yes

  • install HTTP::Date

上記を繰り返す

  • install Net::SSLeay :warning:不可

  • y

  • bye

Perlコンパイル

perl5

Perl Source

OpenWrt上でのコンパイルはdumpが無い為、不可

opkg install coreutils-split coreutils-chmod coreutils-comm

削除

service webmin stop
rm -rf /etc/init.d/webmin
rm -rf /etc/init.d/webmin.old
sed -i "/bin:x:2:/d" /etc/group
sed -i "/webmin/d" /etc/services
/etc/webmin/uninstall.sh

参考資料(感謝:relaxed:

あとがき

  • インストール後再起動すると、webminが起動しなくなったが、
    デフォルトの/tmp(/ver)にログファイルディレクトリ指定していた為必要ファイルが消えていたからだ笑

  • cat << "EOS" | sed で書き出してみると、tabが入らない
    sedなのだからspaceで良かった。。。

  • Net::SSLeayが入らないからSSL暗号化は使えない、さて
    config_h.SHが無いと言うので/usr/lib/perl5/5.28/COREに入れてみた
    今度はperl.hが無いと言うので入れてみた
    config_h.Sを入れたがconfig.hが無いと言われた ひゃ~
    環境用意して移植するかな・・・

0
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
0
0