#!/bin/bash # LXC container env setup script and gittylab compiler for all routers print_success() { echo -e "\e[32m${@}\e[0m"; } print_error() { echo -e "\e[31m${@}\e[0m"; } if [ `whoami` != "root" ] && [ `whoami` != "forge" ] && [ `whoami` != "homestead" ] && [ `whoami` != "vagrant" ]; then print_error "You must be root to run this script!" exit 1 fi echo "Updating apt..." sudo_output=$(sudo bash -c "apt-get update 2>&1; echo $?") sudo_result=$? aptget_result=$(echo "${sudo_output}"| tail -1) echo "${sudo_output}" # Check results if [ ${sudo_result} -eq 0 ]; then if [ ${aptget_result} -eq 0 ]; then print_success "Updated apt." else print_error "Failed to apt, apt-get error!" fi else print_error "Failed to update apt, sudo error!" exit 1 fi echo "Installing openssh-server" sudo_output=$(sudo bash -c "apt-get -y install openssh-server 2>&1; echo $?") sudo_result=$? aptget_result=$(echo "${sudo_output}"| tail -1) echo "${sudo_output}" # Check results if [ ${sudo_result} -eq 0 ]; then if [ ${aptget_result} -eq 0 ]; then print_success "Installed openssh-server." else print_error "Failed to install openssh-server, apt-get error!" fi else print_error "Failed to install openssh-server, sudo error!" exit 1 fi sshd_config='/etc/ssh/sshd_config' sudo mv $sshd_config $sshd_config.bak sudo rm -f $sshd_config echo "# SSH Config Port 22 Protocol 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key UsePrivilegeSeparation yes KeyRegenerationInterval 3600 ServerKeyBits 1024 SyslogFacility AUTH LogLevel INFO LoginGraceTime 120 PermitRootLogin yes StrictModes yes RSAAuthentication yes PubkeyAuthentication yes IgnoreRhosts yes RhostsRSAAuthentication no HostbasedAuthentication no PermitEmptyPasswords no ChallengeResponseAuthentication no X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes AcceptEnv LANG LC_* UsePAM yes Subsystem sftp internal-sftp Match group sftp ChrootDirectory %h X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp " | sudo tee $sshd_config echo "Restarting SSH service..." sudo service ssh restart echo "Creating user and group..." sudo groupadd sftp echo "Enter username for sftp: " read sftp_user echo "Enter password for sftp: " stty -echo read sftp_passwd stty echo sudo useradd -m $sftp_user -g sftp -s /bin/false echo "$sftp_user:$sftp_passwd" | sudo chpasswd sudo mkdir -p /home/$sftp_user/files sudo chown root:root /home/$sftp_user sudo chown $sftp_user:sftp /home/$sftp_user/files sudo chmod 755 /home/$sftp_user sudo chmod 770 /home/$sftp_user/files echo "FTP INSTALL FINISHED! :)" # Install code server: curl -fsSL https://code-server.dev/install.sh | sh sudo systemctl enable --now code-server@root sudo apt-get install -y gawk libncurses5-dev libz-dev zlib1g-dev git ccache pkg-config sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib nano sudo apt install gettext git libncurses-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget sudo systemctl restart code-server@root # Ask user for choice: echo "What router do you want to build packages for today?" select opt in "x86" "Gli gl-a1300, Gli bl1300" "TPLink Archer C7, Gli Crete ar750" "ASUS RT-ac88u" "Linksys E8450, BPI-R64" "gl-mt1300" "Linksys WRT32x, AC3200acm" "glinet-xe300, gli Shadow, Slate" "mt300nv2 Yellow mini"; do case $opt in "x86") sdk="https://downloads.openwrt.org/releases/21.02.7/targets/x86/64/openwrt-sdk-21.02.7-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-21.02.7-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz" folder="openwrt-sdk-21.02.7-x86-64_gcc-8.4.0_musl.Linux-x86_64" ;; "Gli gl-a1300, Gli bl1300") sdk="https://downloads.openwrt.org/releases/23.05.0-rc2/targets/ipq40xx/generic/openwrt-sdk-23.05.0-rc2-ipq40xx-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz" file="openwrt-sdk-23.05.0-rc2-ipq40xx-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz" folder="openwrt-sdk-23.05.0-rc2-ipq40xx-generic_gcc-12.3.0_musl_eabi.Linux-x86_64" ;; "TPLink Archer C7, Gli Crete ar750") sdk="https://downloads.openwrt.org/releases/22.03.3/targets/ath79/generic/openwrt-sdk-22.03.3-ath79-generic_gcc-11.2.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-22.03.3-ath79-generic_gcc-11.2.0_musl.Linux-x86_64.tar.xz" folder="openwrt-sdk-22.03.3-ath79-generic_gcc-11.2.0_musl.Linux-x86_64" ;; "ASUS RT-ac88u") sdk="https://downloads.openwrt.org/releases/22.03.5/targets/bcm53xx/generic/openwrt-sdk-22.03.5-bcm53xx-generic_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz" file="openwrt-sdk-22.03.5-bcm53xx-generic_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz" folder="openwrt-sdk-22.03.5-bcm53xx-generic_gcc-11.2.0_musl_eabi.Linux-x86_64" ;; "Linksys E8450, BPI-R64") sdk="https://downloads.openwrt.org/releases/22.03.5/targets/mediatek/mt7622/openwrt-sdk-22.03.5-mediatek-mt7622_gcc-11.2.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-22.03.5-mediatek-mt7622_gcc-11.2.0_musl.Linux-x86_64.tar.xz" folder="openwrt-sdk-22.03.5-mediatek-mt7622_gcc-11.2.0_musl.Linux-x86_64" ;; "gl-mt1300") sdk="https://downloads.openwrt.org/releases/21.02.6/targets/ramips/mt7621/openwrt-sdk-21.02.6-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-21.02.6-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64.tar.xz" folder="openwrt-sdk-21.02.6-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64" ;; "Linksys WRT32x, AC3200acm") sdk="https://downloads.openwrt.org/releases/22.03.0/targets/mvebu/cortexa9/openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz" file="openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz" folder="openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64" ;; "glinet-xe300, gli Shadow, Slate") sdk="https://downloads.openwrt.org/releases/22.03.0/targets/ath79/nand/openwrt-sdk-22.03.0-ath79-nand_gcc-11.2.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64.tar.xz" folder="openwrt-sdk-22.03.0-mvebu-cortexa9_gcc-11.2.0_musl_eabi.Linux-x86_64" ;; "mt300nv2 Yellow mini") sdk="https://downloads.openwrt.org/releases/21.02.3/targets/ramips/mt76x8/openwrt-sdk-21.02.3-ramips-mt76x8_gcc-8.4.0_musl.Linux-x86_64.tar.xz" file="openwrt-sdk-21.02.3-ramips-mt76x8_gcc-8.4.0_musl.Linux-x86_64.tar.xz" folder="openwrt-sdk-21.02.3-ramips-mt76x8_gcc-8.4.0_musl.Linux-x86_64" ;; *) echo "Invalid option";; esac break done #remove existing files rm $file rm -R $folder # Download and extract openwrt SDK: if [[ ! -f $file ]]; then wget $sdk tar xf $file fi #change dir to SDK folder cd $folder #add .po lang support ./scripts/feeds update -a ./scripts/feeds install -a ./scripts/feeds update packages make menuconfig git clone https://github.com/openwrt-dev/po2lmo.git tools/po2lmo cd tools/po2lmo make && sudo make install cd .. cd .. base_url="https://gittylab.com/ben/" gitapps=( "luci-app-frigate" "luci-app-easymesh" "luci-app-atinout" "luci-app-cellled" "luci-app-mmconfig" "luci-app-smstools3" "luci-app-modeminfo" "luci-app-btcpayserver" "luci-theme-privaterouter" "luci-app-nodered" "luci-app-autogpt" "luci-app-megamedia" "luci-app-rtorrent" "luci-app-webtop" "luci-app-shortcutmenu" "luci-app-plex" "luci-app-filebrowser" "luci-app-nextcloud" "luci-app-seafile" "luci-app-heimdall" "luci-app-motioneye" "luci-app-joplin" "luci-app-ghostblog" "luci-app-emby" "luci-app-jellyfin" "luci-app-prowlarr" "luci-app-wordpress" "luci-app-gitea" "luci-app-libreddit" "luci-app-whoogle" "luci-app-vaultwarden" "luci-app-mastodon" "luci-app-discourse" "luci-app-gotify" "luci-app-jitsi" "luci-app-owncast" "luci-app-neko" "luci-app-alltube" "luci-app-bookstack" "luci-app-searxng" "luci-app-homeassistant" "luci-app-photoprism" "luci-app-qbittorrent" "luci-app-simplex" "luci-app-chatgpt" "luci-app-lxc-attach" "luci-app-fileassistant" ) # Ask user if they want to clone all gittylab packages: read -p "Do you want to clone all openwrt packages from gittylab? [yes/no] " gitchoice if [[ $gitchoice == "yes" ]]; then for gitapp in "${gitapps[@]}"; do # Clone the app git clone "${base_url}${gitapp}.git" "package/$gitapp" # Find directories named "libexec" and apply chmod +x to them and their contents recursively find . -type d -name "libexec" -exec chmod -R +x {} \; echo "Permissions have been set for all 'libexec' directories and their contents." # Compile the app using OpenWRT SDK make package/$gitapp/clean ./scripts/feeds update -a ./scripts/feeds install -a make package/$gitapp/compile done else read -p "What single openwrt package do you want to clone and build today? " appname # Clone the app git clone "${base_url}${appname}.git" "package/appname" # Find directories named "libexec" and apply chmod +x to them and their contents recursively find . -type d -name "libexec" -exec chmod -R +x {} \; echo "Permissions have been set for all 'libexec' directories and their contents." # Compile the app using OpenWRT SDK make package/$appname/clean ./scripts/feeds update -a ./scripts/feeds install -a make package/$appname/compile done