Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import os
- def run_command(command):
- try:
- subprocess.run(command, shell=True, check=True)
- except subprocess.CalledProcessError as e:
- print(f"Error executing command: {command}\n{e}")
- def download_go():
- run_command("wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz")
- def install_go():
- run_command("sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz")
- def update_system():
- run_command("sudo apt-get update")
- run_command("sudo apt-get install -y unzip zip git")
- def set_timezone():
- run_command("sudo ln -fs /usr/share/zoneinfo/Asia/Bangkok /etc/localtime && sudo dpkg-reconfigure -f noninteractive tzdata")
- def configure_profile():
- profile_path = os.path.expanduser("~/.profile")
- with open(profile_path, "a") as profile_file:
- profile_file.write("\nexport PATH=$PATH:/usr/local/go/bin\n")
- profile_file.write("export GOROOT=/usr/local/go\n")
- profile_file.write("export GOPATH=$HOME\n")
- profile_file.write("export PATH=$GOPATH/bin:$GOROOT/bin:$PATH\n")
- run_command("source ~/.profile")
- def install_go_modules():
- go_modules = [
- "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/fckveza/VHtearCryptoutil",
- "github.com/pmezard/go-difflib/difflib",
- "github.com/skip2/go-qrcode",
- "github.com/slayer/autorestart",
- "github.com/tidwall/sjson"
- ]
- run_command("go env -w GO111MODULE=off")
- for module in go_modules:
- run_command(f"go get -u {module}")
- def main():
- download_go()
- install_go()
- update_system()
- set_timezone()
- configure_profile()
- install_go_modules()
- print("Installation completed. Please restart your server.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement