OpenWrt SNAPSHOT専用 パッケージインストール

:flag_jp: Japanese notation

![OpenWrt_icon.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/5490ebb4-460f-613f-7f28-d469738fc8d5.png)

# 初めに
:::note
### APKバージョンSNAPSHOT専用
~~SNAPSHOTの場合、あとからインストール出来なくなるので、とりあえず入れちゃいましょうセットです~~
普通にパッケージアップグレード出来ました
:::

# インストール
:::note

### SNAPSHOT専用
```sh
###APKアップデート
apk update

### LuCi
apk add luci

#LuCi日本語化
apk add luci-i18n-base-ja 
apk add luci-i18n-firewall-ja

### Dashboard
apk add luci-i18n-dashboard-ja

### TTYD
apk add luci-i18n-ttyd-ja

### SFTP server
apk add openssh-sftp-server

### BusyBoxフルバージョン
apk add coreutils

### CPU負荷分散
apk add irqbalance
uci set irqbalance.irqbalance=irqbalance
uci set irqbalance.irqbalance.enabled='1'
uci commit irqbalance
/etc/init.d/irqbalance start

### SQM(Smart Queue Management)
#! /bin/sh
DOWNLOAD='0' #初期値
UPLOAD='0' #初期値
apk add luci-i18n-sqm-ja
. /lib/functions/network.sh
network_flush_cache
network_find_wan6 NET_IF6
network_get_physdev NET_L2D6 "${NET_IF6}"
uci set sqm.@queue[0].enabled='1'
uci set sqm.@queue[0].interface=${NET_L2D6}
uci set sqm.@queue[0].download=${DOWNLOAD}
uci set sqm.@queue[0].upload=${UPLOAD}
uci commit sqm
/etc/init.d/sqm start
/etc/init.d/sqm enable

### QoS(Network Traffic Control)
#! /bin/sh
apk add tc-mod-iptables
apk add luci-i18n-qos-ja
# reboot

### ネットワーク統計インターフェイス
#! /bin/sh
apk add luci-i18n-statistics-ja
/etc/init.d/collectd enable
/etc/init.d/rpcd restart

### 帯域幅モニター
#! /bin/sh
apk add luci-i18n-nlbwmon-ja
# reboot

### WiFiスケジュール
#! /bin/sh
apk add luci-i18n-wifischedule-ja

### 追加テーマ
#! /bin/sh
# OpnWrt
apk add luci-theme-openwrt
# マテリアル
apk add luci-theme-material
# モダン
apk add luci-theme-openwrt-2020

### Attended Sysupgrade
apk add luci-i18n-attendedsysupgrade-ja

### IPK
apk add luci-lib-ipkg

### USB
apk add block-mount
apk add kmod-usb-storage
apk add kmod-usb-storage-uas
apk add usbutils
apk add gdisk
apk add libblkid1
# USBポート_LEDトリガー
apk add kmod-usb-ledtrig-usbport
apk add luci-app-ledtrig-usbport
# reboot

### ファイルシステム
# FAT32
apk add dosfstools
apk add kmod-fs-vfat
# ext4
apk add e2fsprogs
apk add kmod-fs-ext4
# f2fs
apk add f2fs-tools
apk add kmod-fs-f2fs
# exFAT
apk add exfat-fsck
apk add kmod-fs-exfat
# NTFS
apk add ntfs-3g
apk add kmod-fs-ntfs3
# HFS & HFS+
apk add hfsfsck
apk add kmod-fs-hfs
apk add kmod-fs-hfsplus

### ハードディスクアイドル
apk add hdparm
apk add hd-idle
apk add luci-i18n-hd-idle-ja

### ストレージ拡張
apk add cfdisk
apk add resize2fs

### 温度
apk add lm-sensors

### ボタン
apk add kmod-button-hotplug

### SAMBA
apk add luci-i18n-samba4-ja
apk add wsdd2
#例: アクセスフリー
NAS="openwrt"
MNT="/mnt/sda"
uci set samba4.@samba[0]=samba
uci set samba4.@samba[0].workgroup='WORKGROUP'
uci set samba4.@samba[0].charset='UTF-8'
uci set samba4.@samba[0].description='Samba on OpenWRT'
uci set samba4.@samba[0].enable_extra_tuning='1'
uci set samba4.@samba[0].interface='lan'
uci set samba4.sambashare=sambashare
uci set samba4.sambashare.name=${NAS}
uci set samba4.sambashare.path=${MNT}
uci set samba4.sambashare.read_only='no'
uci set samba4.sambashare.force_root='1'
uci set samba4.sambashare.guest_ok='yes'
uci set samba4.sambashare.inherit_owner='yes'
uci set samba4.sambashare.create_mask='0777'
uci set samba4.sambashare.dir_mask='0777'
uci commit samba4
/etc/init.d/samba4 enable
/etc/init.d/samba4 restart
/etc/init.d/wsdd2 restart

### TCPDUMP
apk add tcpdump
uci add dropbear dropbear
uci set dropbear.@dropbear[-1].RootPasswordAuth="on"
uci set dropbear.@dropbear[-1].PasswordAuth="on"
uci set dropbear.@dropbear[-1].GatewayPorts='on'
uci set dropbear.@dropbear[-1].Port="23" #任意のポート
uci commit dropbear
/etc/init.d/dropbear restart

### IPERF3
apk add iperf3
wget --no-check-certificate -O /etc/init.d/iperf3 https://raw.githubusercontent.com/site-u2023/iperf/main/iperf3
chmod +x /etc/init.d/iperf3
NET_IF="lan"
. /lib/functions/network.sh
network_flush_cache
network_get_ipaddr NET_ADDR "${NET_IF}"
sed -i -e "s/192.168.1.1/${NET_ADDR}/g" /etc/init.d/iperf3
# /etc/init.d/iperf3 enable
# reboot
```
:::
:::note
### AdGuard HOME
- パッケージインストール及び設定
```sh
apk add adguardhome
service adguardhome enable
service adguardhome start
NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')
echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"
uci set dhcp.@dnsmasq[0].noresolv="0"
uci set dhcp.@dnsmasq[0].cachesize="1000"
uci set dhcp.@dnsmasq[0].rebind_protection='0'
uci set dhcp.@dnsmasq[0].port="54"
uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="${NET_ADDR}"
uci -q delete dhcp.lan.dhcp_option
uci -q delete dhcp.lan.dns
uci add_list dhcp.lan.dhcp_option='6,'"${NET_ADDR}" 
uci add_list dhcp.lan.dhcp_option='3,'"${NET_ADDR}"
for OUTPUT in $(ip -o -6 addr list br-lan scope global | awk '{ split($4, ip_addr, "/"); print ip_addr[1] }')
do
	echo "Adding $OUTPUT to IPV6 DNS"
	uci add_list dhcp.lan.dns=$OUTPUT
done
uci commit dhcp
/etc/init.d/dnsmasq restart
# DNSインターセプト@IPTables(ファイアウォール3)
# IPV4
uci set firewall.adguardhome_dns_53='redirect'
uci set firewall.adguardhome_dns_53.src='lan'
uci set firewall.adguardhome_dns_53.proto='tcp udp'
uci set firewall.adguardhome_dns_53.src_dport='53'
uci set firewall.adguardhome_dns_53.target='DNAT'
uci set firewall.adguardhome_dns_53.name='Adguard Home'
uci set firewall.adguardhome_dns_53.dest='lan'
uci set firewall.adguardhome_dns_53.dest_port='53'
# IPV6
uci set firewall.adguardhome_dns_53.family="any"
uci commit firewall
/etc/init.d/firewall restart

# reboot
```
- ログイン
http://192.168.1.1:3000/

:::