Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import subprocess
- def change_hostname():
- new_hostname = input("กรุณาใส่ชื่อโฮสต์ใหม่ (หรือกด Enter เพื่อข้าม): ")
- if new_hostname.strip():
- subprocess.run(["sudo", "hostnamectl", "set-hostname", new_hostname], check=True)
- print(f"โฮสต์เนมถูกเปลี่ยนเป็น {new_hostname} แล้ว")
- else:
- print("ข้ามการเปลี่ยนชื่อโฮสต์")
- def change_password():
- new_password = input("กรุณาใส่รหัสผ่านใหม่ (หรือกด Enter เพื่อข้าม): ")
- if new_password.strip():
- subprocess.run(f"echo -e '{new_password}\\n{new_password}' | sudo passwd", shell=True, check=True)
- print("รหัสผ่านถูกเปลี่ยนเรียบร้อยแล้ว")
- else:
- print("ข้ามการเปลี่ยนรหัสผ่าน")
- def check_speed():
- print("กำลังตรวจสอบความเร็วอินเทอร์เน็ต...")
- try:
- subprocess.run(["speedtest-cli"], check=True)
- except FileNotFoundError:
- print("ไม่พบ speedtest-cli ในระบบ กำลังติดตั้ง...")
- subprocess.run(["sudo", "apt-get", "install", "-y", "python3-pip"], check=True)
- subprocess.run(["pip3", "install", "speedtest-cli"], check=True)
- subprocess.run(["speedtest-cli"], check=True)
- def install_go_and_dependencies():
- print("กำลังติดตั้ง Go และไลบรารีที่จำเป็น...")
- subprocess.run(["wget", "https://go.dev/dl/go1.21.0.linux-amd64.tar.gz"], check=True)
- subprocess.run(["sudo", "rm", "-rf", "/usr/local/go"], check=True)
- subprocess.run(["sudo", "tar", "-C", "/usr/local", "-xzf", "go1.21.0.linux-amd64.tar.gz"], check=True)
- subprocess.run(["sudo", "apt-get", "update"], check=True)
- subprocess.run(["sudo", "apt-get", "install", "-y", "unzip", "zip", "git"], check=True)
- subprocess.run(["sudo", "ln", "-fs", "/usr/share/zoneinfo/Asia/Bangkok", "/etc/localtime"], check=True)
- subprocess.run(["sudo", "dpkg-reconfigure", "-f", "noninteractive", "tzdata"], check=True)
- with open(os.path.expanduser("~/.profile"), "a") as profile:
- profile.write('\nexport PATH=$PATH:/usr/local/go/bin')
- profile.write('\nexport GOROOT=/usr/local/go')
- profile.write('\nexport GOPATH=$HOME')
- profile.write('\nexport PATH=$GOPATH/bin:$GOROOT/bin:$PATH')
- subprocess.run(["source", os.path.expanduser("~/.profile")], shell=True, check=True)
- go_get_dependencies = [
- "github.com/opalmer/check-go-version/api",
- "github.com/shirou/gopsutil/disk",
- "github.com/shirou/gopsutil/host",
- "github.com/shirou/gopsutil/mem",
- "github.com/tidwall/gjson",
- "github.com/valyala/fasthttp",
- "github.com/kardianos/osext",
- "github.com/panjf2000/ants",
- "github.com/asaskevich/govalidator",
- "github.com/dchest/siphash",
- "golang.org/x/net/http2",
- "github.com/fatih/color",
- "github.com/ddosify/go-faker/faker",
- "golang.org/x/crypto/hkdf",
- "golang.org/x/crypto/curve25519",
- "github.com/lynn9388/supsub",
- "github.com/danielgtaylor/unistyle",
- "github.com/leekchan/timeutil",
- #"github.com/8ff/gpt/pkg/gpt_3_5_turbo",
- #"github.com/sashabaranov/go-openai",
- "github.com/boombuler/barcode",
- "github.com/dgrr/http2",
- "github.com/fckveza/VHtearCryptoutil",
- "github.com/pmezard/go-difflib/difflib",
- "github.com/skip2/go-qrcode",
- "github.com/slayer/autorestart",
- "github.com/tidwall/sjson"
- ]
- for dep in go_get_dependencies:
- subprocess.run(["go", "get", "-u", dep], check=True)
- if __name__ == "__main__":
- change_hostname()
- change_password()
- check_speed()
- install_go_and_dependencies()
- print("ติดตั้งเสร็จเรียบร้อย กรุณารีสตาร์ทเซิร์ฟเวอร์")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement