Skip to content

Commit 08522fa

Browse files
committed
Update
1 parent 758b382 commit 08522fa

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

htdocs/image.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<!-- image.html -->
21
<!DOCTYPE html>
3-
<html lang="en">
2+
<html lang="ja">
43
<head>
54
<meta charset="UTF-8">
65
<meta name="viewport" content="width=device-width, initial-scale=1.0">

setting.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ PASSWORD="IfYouBelieveInAPowerOfMagicIcanChangeYourMind"
33
INTERFACE=wlan0
44
IP_ADDRESS=192.168.11.XXX
55
ROUTERS=192.168.11.1
6-
DNS=192.168.11.11
6+
DNS=192.168.11.11

setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ sed -i "3s/.*/$NEW_HOST_PART/;3a\\" target.txt
3535
sudo cp target.txt /usr/local/apache2/cgi-bin/
3636
sudo cp target.txt /usr/local/apache2/backup/
3737
sudo chmod 775 /usr/local/apache2/backup/target.txt
38-
sudo chmod 755 /usr/local/apache2/cgi-bin/target.txt
38+
sudo chmod 755 /usr/local/apache2/cgi-bin/target.txt
39+

start.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# ローカルIPアドレスを取得
4+
IP_ADDRESS=$(hostname -I | awk '{print $1}')
5+
6+
# オプションを表示
7+
echo "選択してください:"
8+
echo "1. 現在のIPアドレスを使用する ($IP_ADDRESS)"
9+
echo "2. IPアドレスを変更する"
10+
read -p "選択 (1/2): " choice
11+
12+
case $choice in
13+
1)
14+
echo "現在のIPアドレス ($IP_ADDRESS) を使用します。"
15+
sed -i "s/IP_ADDRESS=192.168.11.[0-9]*/IP_ADDRESS=$IP_ADDRESS/" setting.txt
16+
echo "IPアドレスが $IP_ADDRESS に変更されました。"
17+
;;
18+
2)
19+
read -p "新しいIPアドレスのホスト部を入力してください (192.168.11.): " host_part
20+
new_ip="192.168.11.$host_part"
21+
# IPアドレスの変更処理
22+
sed -i "s/IP_ADDRESS=192.168.11.[0-9]*/IP_ADDRESS=$new_ip/" setting.txt
23+
echo "IPアドレスが $new_ip に変更されました。"
24+
;;
25+
*)
26+
echo "無効な選択です。"
27+
exit 1
28+
;;
29+
esac
30+
31+
source setting.txt
32+
33+
#/etc/dhcpcd.confの変更内容を削除
34+
sudo sed -i '/interface wlan0/,/static domain_name_servers=[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/d' /etc/dhcpcd.conf
35+
36+
#/etc/dhcpcd.confの内容を変更
37+
echo "interface $INTERFACE" | sudo tee -a /etc/dhcpcd.conf
38+
echo "static ip_address=$IP_ADDRESS/24" | sudo tee -a /etc/dhcpcd.conf
39+
echo "static routers=$ROUTERS" | sudo tee -a /etc/dhcpcd.conf
40+
echo "static domain_name_servers=${DNS//,/ }" | sudo tee -a /etc/dhcpcd.conf
41+
42+
#Wi-Fi設定
43+
echo -e "\nnetwork={\n\tssid=\"$SSID\"\n\tpsk=\"$PASSWORD\"\n}" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null
44+
45+
# setting.txtからIPアドレスを抽出してホスト部を取得
46+
IP_ADDRESS=$(grep 'IP_ADDRESS' setting.txt | cut -d= -f2)
47+
HOST_PART=$(echo $IP_ADDRESS | cut -d. -f4)
48+
49+
# ホスト部の前に1000を足す
50+
NEW_HOST_PART="1000${HOST_PART}"
51+
52+
# target.txtの2行目と3行目に新しいホスト部を保存
53+
sed -i "2s/.*/$NEW_HOST_PART/" target.txt
54+
sed -i "3s/.*/$NEW_HOST_PART/;3a\\" target.txt
55+
56+
#target.txtの移動
57+
sudo cp target.txt /usr/local/apache2/cgi-bin/
58+
sudo cp target.txt /usr/local/apache2/backup/
59+
sudo chmod 775 /usr/local/apache2/backup/target.txt
60+
sudo chmod 755 /usr/local/apache2/cgi-bin/target.txt

0 commit comments

Comments
 (0)