OpenWrt 専用設定ツール all in one scripts

:flag_jp:Japanese notation
![OpenWrt_icon.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/cc2e83af-44dd-e98a-97c2-36e53597df85.png)

# はじめに
::: note
### 初心者対応構成
- Windowsからの導入手順
- スクリプトでの自動設定
- [UCI (ttyd)](https://openwrt.org/docs/guide-user/base-system/uci)、[Webコンソール (LuCi)](https://openwrt.org/docs/guide-user/luci/start)、[ファイラー (SFTP)](https://openwrt.org/docs/guide-user/services/nas/sftp.server)にて比較作業がおススメ:exclamation:
:::

# [all in one scripts](https://github.com/site-u2023/aios)
:::note
![aios.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/69e87faf-fb43-4c0f-b523-00fe1b2c9809.png)
サポート：バージョン19.07～（スナップショット対応）
バージョンβ：2025年6月5日

GitHubからスクリプトをダウンロードして動作します

### デバイスアクセス
<details><summary>パワーシェル</summary>

- キー入力：**`Win`+`x` > `a` > `はい`**

[UCI（SSH）アクセス](https://openwrt.org/docs/guide-quick-start/sshadministration)
```powershell:powershell:初期設定用
ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-rsa root@192.168.1.1
```
- root@192.168.1.1's password:`初期値：パスワード無し`

<details><summary>SSHログイン出来ない場合:exclamation:</summary>

  - `%USERPROFILE%\.ssh\known_hosts` ※Windows隠しファイル
```powershell:powershell
Clear-Content .ssh\known_hosts -Force 
```
---
</details>

<details><summary>OpenSSHのインストールが無い場合:exclamation:</summary>

- 機能の確認
※Windows 10 Fall Creators Update(1709)以降標準搭載
```powershell:powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
```
- 機能のインストール
```powershell:powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
```
---
</details>

<details><summary>パワーシェル７のインストールとショートカット作成</summary>

```powershell:powershell
$currentVersion = $PSVersionTable.PSVersion
Write-Host "Current PowerShell version: $($currentVersion)"
$installed = Get-Command pwsh -ErrorAction SilentlyContinue
if ($installed) {
    Write-Host "PowerShell 7 is already installed. Skipping installation."
} else {
    Write-Host "Installing PowerShell 7..."
    $url = "https://aka.ms/install-powershell.ps1"
    Invoke-WebRequest -Uri $url -OutFile "install-powershell.ps1"
    .\install-powershell.ps1
    Write-Host "PowerShell 7 installation completed."
}
$desktop = [Environment]::GetFolderPath("Desktop")
$shortcutPath = "$desktop\PowerShell 7 (Admin).lnk"
$targetPath = "C:\Program Files\PowerShell\7\pwsh.exe"
$arguments = "-Command Start-Process pwsh -Verb runAs"
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $targetPath
$shortcut.Arguments = $arguments
$shortcut.Description = "PowerShell 7 Administrator Shortcut"
$shortcut.WorkingDirectory = "$HOME"
$shortcut.IconLocation = $targetPath
$shortcut.Save()
Write-Host "PowerShell 7 administrator shortcut has been created."

```
---
</details>

---
</details>

### [インストール](https://github.com/site-u2023/aios-package?tab=readme-ov-file#aios-package)
<details><summary>aiosパッケージ</summary>

リリースビルド (opkg)
```sh
opkg install https://github.com/site-u2023/aios-package/releases/download/ipk0.0/aios_all.ipk
```

<details><summary>バージョン19.07</summary>

```sh
wget -O /tmp/aios_all.ipk "https://github.com/site-u2023/aios-package/releases/download/ipk0.0/aios_all.ipk"; opkg install /tmp/aios_all.ipk
```
---
</details>

スナップショットビルド (apk)
```sh
wget -O /tmp/aios.apk "https://github.com/site-u2023/aios-package/releases/download/apk0.1/aios.apk"; apk add --allow-untrusted /tmp/aios.apk
```
---
</details>

### 利用方法
<details><summary>コマンド実行</summary>


```sh
aios
```

### 国番号を指定する
例: JP
```sh
aios JP
```

---
</details>
:::


# インターネット設定: 日本専用
::: note warn
### デバイス接続
**要HGW（ONUなど）直結**
※上位ルーターがISPのPDを配布している場合、ルーター配下でも正常動作します

### ルーター配下でインターネット設定する場合
<details><summary>上位ルーターのPD設定</summary>

- 一般市販ルーターの場合：
「IPv6パススルー」「パススルー機能」「IPv6ブリッジ」などを有効にする

- OpenWrtの場合：
```
uci set network.lan.ip6assign='64'
uci set dhcp.lan.dhcpv6='relay'
uci set dhcp.lan.ra='relay'
uci set dhcp.lan.ndp='relay'
uci set dhcp.lan.ra_management='0'
uci set dhcp.wan.dhcpv6='relay'
uci set dhcp.wan.ra='relay'
uci set dhcp.wan.ndp='relay'
uci commit network
uci commit dhcp
/etc/init.d/network reload
/etc/init.d/odhcpd restart
```

---
</details>
:::

:::note
### 自動構成: MAP-E / DS-LITE / NURO HIKARI

自動検出結果: <インターネットサービスプロバイダ>

### MAP-E: OCN / V6 PLUS / NURO HIKARI
<details><summary>MAP-E: OCN / V6 PLUS / NURO HIKARI</summary>

- OCN / V6 PLUS / NURO HIKARI
- 設定を復元します
---
</details>

### DS-LITE: TRANSIX / CROSS PASS / V6 CONNECT
<details><summary>DS-LITE: TRANSIX / CROSS PASS / V6 OPTION</summary>

- TRANSIX EAST JAPAN
- TRANSIX WEST JAPAN
- クロスパス
- V6オプション
- 設定を復元します
---
</details>
:::

# パッケージ管理
:::note
### COMMON

<details><summary>基本システム機能</summary>

[luci](https://openwrt.org/docs/guide-user/luci/start)  
[luci-i18n-base]()  
[ttyd](https://openwrt.org/packages/pkgdata/ttyd)  
[openssh-sftp-server](https://openwrt.org/docs/guide-user/services/nas/sftp.server)  
[luci-app-commands](https://openwrt.org/packages/pkgdata/luci-app-commands)

---
</details>

<details><summary>システム管理</summary>

[irqbalance](https://openwrt.org/packages/pkgdata/irqbalance)

---
</details>

<details><summary>ネットワーク管理</summary>

[luci-app-qos](https://openwrt.org/packages/pkgdata/luci-app-qos)  
[luci-app-sqm](https://openwrt.org/packages/pkgdata/luci-app-sqm)  
[luci-app-statistics](https://openwrt.org/packages/pkgdata/luci-app-statistics)  
[nlbwmon](https://openwrt.org/packages/pkgdata/nlbwmon)  
[wifischedule](https://openwrt.org/packages/pkgdata/wifischedule)  
[luci-app-wol](https://openwrt.org/packages/pkgdata/luci-app-wol)  
[luci-app-ddns](https://openwrt.org/packages/pkgdata/luci-app-ddns)

---
</details>

<details><summary>セキュリティツール</summary>

[znc-mod-fail2ban](https://openwrt.org/packages/pkgdata/znc)  
[banip](https://openwrt.org/packages/pkgdata/banip)

---
</details>

<details><summary>システム監視</summary>

[luci-app-watchcat](https://openwrt.org/packages/pkgdata/luci-app-watchcat)

---
</details>

<details><summary>ネットワーク診断ツール</summary>

[htop](https://openwrt.org/packages/pkgdata/htop)  
[mtr](https://github.com/traviscross/mtr)  
[nmap](https://openwrt.org/packages/pkgdata/nmap)  
[tcpdump](https://openwrt.org/packages/pkgdata/tcpdump)

---
</details>

<details><summary>テーマおよびダッシュボード</summary>

[luci-theme-openwrt](https://openwrt.org/packages/pkgdata/luci-theme-openwrt)  
[attendedsysupgrade-common](https://openwrt.org/packages/pkgdata/attendedsysupgrade-common)

---
</details>

<details><summary>ユーティリティ</summary>

[luci-mod-dashboard](https://openwrt.org/packages/pkgdata/luci-mod-dashboard)  
[luci-app-filebrowser](https://github.com/xiaozhuai/luci-app-filebrowser)
[wireguard-tools](https://openwrt.org/packages/pkgdata/wireguard-tools)

---
</details>
:::

:::note
### DEFAULT

<details><summary>追加機能</summary>

[luci-app-cpu-perf](https://github.com/gSpotx2f/luci-app-cpu-perf)  
[luci-app-cpu-status](https://github.com/gSpotx2f/luci-app-cpu-status)  
[luci-app-temp-status](https://github.com/gSpotx2f/luci-app-temp-status)  
[internet-detector](https://github.com/gSpotx2f/luci-app-internet-detector)  
[luci-app-log-viewer](https://github.com/gSpotx2f/luci-app-log)  
[luci-theme-argon](https://github.com/jerrykuku/luci-theme-argon)  
[luci-app-diskman](https://github.com/lisaac/luci-app-diskman)

---
</details>
:::

:::note
### RELEASE19

<details><summary>追加機能</summary>

[luci-app-cpu-status-mini](https://github.com/gSpotx2f/luci-app-cpu-status-mini)  
[luci-app-log](https://github.com/gSpotx2f/luci-app-log)  
[luci-app-diskman](https://github.com/lisaac/luci-app-diskman)

---
</details>
:::

:::note
### SNAPSHOT

<details><summary>追加機能</summary>

---
</details>
:::

:::note
### COMMON (USB)

<details><summary>USBストレージ</summary>

[kmod-usb-storage](https://openwrt.org/packages/pkgdata/kmod-usb-storage)  
[dosfstools](https://openwrt.org/packages/pkgdata/dosfstools)  
[e2fsprogs](https://openwrt.org/packages/pkgdata/e2fsprogs)  
[f2fs-tools](https://openwrt.org/packages/pkgdata/f2fs-tools)  
[exfat-fsck](https://openwrt.org/packages/pkgdata/exfat-fsck)  
[ntfs-3g](https://openwrt.org/packages/pkgdata/ntfs-3g)  
[hfsfsck](https://openwrt.org/packages/pkgdata/hfsfsck)  
[hdparm](https://openwrt.org/packages/pkgdata/hdparm)

---
</details>

<details><summary>ファイル共有</summary>

[luci-app-samba4](https://openwrt.org/packages/pkgdata/luci-app-samba4)

---
</details>
:::

# [問題](https://github.com/site-u2023/aios/issues)
::: note warn
### ご質問、バグレポートはこちら
<details><summary>lssues</summary>

[サポート](https://github.com/site-u2023/aios/issues/3)

[バグ](https://github.com/site-u2023/aios/issues/2)

---
</details>
:::
::: note warn
### nuro 光 map-e 情報求む
<details><summary>nuro 光 map-e</summary>

[nuro 光 map-e](https://github.com/site-u2023/aios/issues/4)

---
</details>
:::
# あとがき
トイレに100ワットなスクリプトを作っています
技術的興味から、多言語対応、並列処理など過剰な仕様です