nginxproxymanager-v5.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. #!/usr/bin/env bash
  2. function header_info {
  3. cat <<"EOF"
  4. _ __ _ ____ __ ___
  5. / | / /___ _(_)___ _ __ / __ \_________ _ ____ __ / |/ /___ _____ ____ _____ ____ _____
  6. / |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/
  7. / /| / /_/ / / / / /> < / ____/ / / /_/ /> </ /_/ / / / / / /_/ / / / / /_/ / /_/ / __/ /
  8. /_/ |_/\__, /_/_/ /_/_/|_| /_/ /_/ \____/_/|_|\__, / /_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/
  9. /____/ v5 /____/ /____/
  10. EOF
  11. }
  12. clear
  13. header_info
  14. echo -e "Loading..."
  15. APP="Nginx Proxy Manager"
  16. var_disk="4"
  17. var_cpu="1"
  18. var_ram="1024"
  19. var_os="debian"
  20. var_version="11"
  21. NSAPP=$(echo ${APP,,} | tr -d ' ')
  22. var_install="${NSAPP}-v5-install"
  23. INTEGER='^[0-9]+$'
  24. YW=$(echo "\033[33m")
  25. BL=$(echo "\033[36m")
  26. RD=$(echo "\033[01;31m")
  27. BGN=$(echo "\033[4;92m")
  28. GN=$(echo "\033[1;92m")
  29. DGN=$(echo "\033[32m")
  30. CL=$(echo "\033[m")
  31. BFR="\\r\\033[K"
  32. HOLD="-"
  33. CM="${GN}✓${CL}"
  34. CROSS="${RD}✗${CL}"
  35. set -Eeuo pipefail
  36. trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
  37. function error_handler() {
  38. local exit_code="$?"
  39. local line_number="$1"
  40. local command="$2"
  41. local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
  42. echo -e "\n$error_message\n"
  43. }
  44. function msg_info() {
  45. local msg="$1"
  46. echo -ne " ${HOLD} ${YW}${msg}..."
  47. }
  48. function msg_ok() {
  49. local msg="$1"
  50. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  51. }
  52. function msg_error() {
  53. local msg="$1"
  54. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  55. }
  56. function PVE_CHECK() {
  57. PVE=$(pveversion | grep "pve-manager/7" | wc -l)
  58. if [[ $PVE != 1 ]]; then
  59. echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
  60. echo -e "Exiting..."
  61. sleep 2
  62. exit
  63. fi
  64. }
  65. function ARCH_CHECK() {
  66. ARCH=$(dpkg --print-architecture)
  67. if [[ "$ARCH" != "amd64" ]]; then
  68. echo -e "\n ❌ This script will not work with PiMox! \n"
  69. echo -e "Exiting..."
  70. sleep 2
  71. exit
  72. fi
  73. }
  74. if command -v pveversion >/dev/null 2>&1; then
  75. if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
  76. NEXTID=$(pvesh get /cluster/nextid)
  77. else
  78. clear
  79. echo -e "⚠ User exited script \n"
  80. exit
  81. fi
  82. fi
  83. if ! command -v pveversion >/dev/null 2>&1; then
  84. if [[ ! -f /lib/systemd/system/npm.service ]]; then
  85. msg_error "No ${APP} Installation Found!";
  86. exit
  87. fi
  88. if (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then
  89. echo "User selected Update"
  90. else
  91. clear
  92. echo -e "⚠ User exited script \n"
  93. exit
  94. fi
  95. fi
  96. function default_settings() {
  97. echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
  98. CT_TYPE="1"
  99. echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
  100. PW=""
  101. echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
  102. CT_ID=$NEXTID
  103. echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
  104. HN=$NSAPP
  105. echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
  106. DISK_SIZE="$var_disk"
  107. echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
  108. CORE_COUNT="$var_cpu"
  109. echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
  110. RAM_SIZE="$var_ram"
  111. echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
  112. BRG="vmbr0"
  113. echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
  114. NET=dhcp
  115. echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
  116. GATE=""
  117. echo -e "${DGN}Disable IPv6: ${BGN}No${CL}"
  118. DISABLEIP6="no"
  119. echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
  120. MTU=""
  121. echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}"
  122. SD=""
  123. echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}"
  124. NS=""
  125. echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
  126. MAC=""
  127. echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
  128. VLAN=""
  129. echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}"
  130. SSH="no"
  131. echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
  132. VERB="no"
  133. echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
  134. }
  135. function advanced_settings() {
  136. CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \
  137. "1" "Unprivileged" ON \
  138. "0" "Privileged" OFF \
  139. 3>&1 1>&2 2>&3)
  140. exitstatus=$?
  141. if [ $exitstatus = 0 ]; then
  142. echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
  143. fi
  144. PW1=$(whiptail --inputbox "Set Root Password (needed for root ssh access)" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  145. exitstatus=$?
  146. if [ $exitstatus = 0 ]; then
  147. if [ -z $PW1 ]; then
  148. PW1="Automatic Login" PW=" "
  149. echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
  150. else
  151. PW="-password $PW1"
  152. echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
  153. fi
  154. fi
  155. CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  156. exitstatus=$?
  157. if [ -z $CT_ID ]; then
  158. CT_ID="$NEXTID"
  159. echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
  160. else
  161. if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi
  162. fi
  163. CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  164. exitstatus=$?
  165. if [ -z $CT_NAME ]; then
  166. HN="$NSAPP"
  167. echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
  168. else
  169. if [ $exitstatus = 0 ]; then
  170. HN=$(echo ${CT_NAME,,} | tr -d ' ')
  171. echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
  172. fi
  173. fi
  174. DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  175. exitstatus=$?
  176. if [ -z $DISK_SIZE ]; then
  177. DISK_SIZE="$var_disk"
  178. echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
  179. else
  180. if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi
  181. if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
  182. echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}"
  183. advanced_settings
  184. fi
  185. fi
  186. CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  187. exitstatus=$?
  188. if [ -z $CORE_COUNT ]; then
  189. CORE_COUNT="$var_cpu"
  190. echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
  191. else
  192. if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi
  193. fi
  194. RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  195. exitstatus=$?
  196. if [ -z $RAM_SIZE ]; then
  197. RAM_SIZE="$var_ram"
  198. echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
  199. else
  200. if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi
  201. fi
  202. BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  203. exitstatus=$?
  204. if [ -z $BRG ]; then
  205. BRG="vmbr0"
  206. echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
  207. else
  208. if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi
  209. fi
  210. NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  211. exitstatus=$?
  212. if [ -z $NET ]; then
  213. NET="dhcp"
  214. echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
  215. else
  216. if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi
  217. fi
  218. GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  219. exitstatus=$?
  220. if [ $exitstatus = 0 ]; then
  221. if [ -z $GATE1 ]; then
  222. GATE1="Default" GATE=""
  223. echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
  224. else
  225. GATE=",gw=$GATE1"
  226. echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
  227. fi
  228. fi
  229. if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then
  230. echo -e "${DGN}Disable IPv6: ${BGN}Yes${CL}"
  231. DISABLEIP6="yes"
  232. else
  233. echo -e "${DGN}Disable IPv6: ${BGN}No${CL}"
  234. DISABLEIP6="no"
  235. fi
  236. MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  237. exitstatus=$?
  238. if [ $exitstatus = 0 ]; then
  239. if [ -z $MTU1 ]; then
  240. MTU1="Default" MTU=""
  241. echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
  242. else
  243. MTU=",mtu=$MTU1"
  244. echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
  245. fi
  246. fi
  247. SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  248. exitstatus=$?
  249. if [ $exitstatus = 0 ]; then
  250. if [ -z $SD ]; then
  251. SD=""
  252. echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}"
  253. else
  254. SX=$SD
  255. SD="-searchdomain=$SD"
  256. echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}"
  257. fi
  258. fi
  259. NS=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  260. exitstatus=$?
  261. if [ $exitstatus = 0 ]; then
  262. if [ -z $NS ]; then
  263. NS=""
  264. echo -e "${DGN}Using DNS Server IP Address: ${BGN}Host${CL}"
  265. else
  266. NX=$NS
  267. NS="-nameserver=$NS"
  268. echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}"
  269. fi
  270. fi
  271. MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  272. exitstatus=$?
  273. if [ $exitstatus = 0 ]; then
  274. if [ -z $MAC1 ]; then
  275. MAC1="Default" MAC=""
  276. echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
  277. else
  278. MAC=",hwaddr=$MAC1"
  279. echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
  280. fi
  281. fi
  282. VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
  283. exitstatus=$?
  284. if [ $exitstatus = 0 ]; then
  285. if [ -z $VLAN1 ]; then
  286. VLAN1="Default" VLAN=""
  287. echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
  288. else
  289. VLAN=",tag=$VLAN1"
  290. echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
  291. fi
  292. fi
  293. if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then
  294. echo -e "${DGN}Enable Root SSH Access: ${BGN}Yes${CL}"
  295. SSH="yes"
  296. else
  297. echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}"
  298. SSH="no"
  299. fi
  300. if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
  301. echo -e "${DGN}Enable Verbose Mode: ${BGN}Yes${CL}"
  302. VERB="yes"
  303. VERB2=""
  304. else
  305. echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
  306. VERB="no"
  307. fi
  308. if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
  309. echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
  310. else
  311. clear
  312. header_info
  313. echo -e "${RD}Using Advanced Settings${CL}"
  314. advanced_settings
  315. fi
  316. }
  317. function install_script() {
  318. if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
  319. header_info
  320. echo -e "${BL}Using Default Settings${CL}"
  321. default_settings
  322. else
  323. header_info
  324. echo -e "${RD}Using Advanced Settings${CL}"
  325. advanced_settings
  326. fi
  327. }
  328. function update_script() {
  329. clear
  330. header_info
  331. RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest |
  332. grep "tag_name" |
  333. awk '{print substr($2, 3, length($2)-4) }')
  334. msg_info "Stopping Services"
  335. systemctl stop openresty
  336. systemctl stop npm
  337. msg_ok "Stopped Services"
  338. msg_info "Cleaning Old Files"
  339. rm -rf /app \
  340. /var/www/html \
  341. /etc/nginx \
  342. /var/log/nginx \
  343. /var/lib/nginx \
  344. /var/cache/nginx &>/dev/null
  345. msg_ok "Cleaned Old Files"
  346. msg_info "Downloading NPM v${RELEASE}"
  347. wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz &>/dev/null
  348. cd nginx-proxy-manager-${RELEASE}
  349. msg_ok "Downloaded NPM v${RELEASE}"
  350. msg_info "Setting up Enviroment"
  351. ln -sf /usr/bin/python3 /usr/bin/python
  352. ln -sf /usr/bin/certbot /opt/certbot/bin/certbot
  353. ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
  354. ln -sf /usr/local/openresty/nginx/ /etc/nginx
  355. sed -i "s+0.0.0+${RELEASE}+g" backend/package.json
  356. sed -i "s+0.0.0+${RELEASE}+g" frontend/package.json
  357. sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf
  358. NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf")
  359. for NGINX_CONF in $NGINX_CONFS; do
  360. sed -i 's+include conf.d+include /etc/nginx/conf.d+g' "$NGINX_CONF"
  361. done
  362. mkdir -p /var/www/html /etc/nginx/logs
  363. cp -r docker/rootfs/var/www/html/* /var/www/html/
  364. cp -r docker/rootfs/etc/nginx/* /etc/nginx/
  365. cp docker/rootfs/etc/letsencrypt.ini /etc/letsencrypt.ini
  366. cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-proxy-manager
  367. ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf
  368. rm -f /etc/nginx/conf.d/dev.conf
  369. mkdir -p /tmp/nginx/body \
  370. /run/nginx \
  371. /data/nginx \
  372. /data/custom_ssl \
  373. /data/logs \
  374. /data/access \
  375. /data/nginx/default_host \
  376. /data/nginx/default_www \
  377. /data/nginx/proxy_host \
  378. /data/nginx/redirection_host \
  379. /data/nginx/stream \
  380. /data/nginx/dead_host \
  381. /data/nginx/temp \
  382. /var/lib/nginx/cache/public \
  383. /var/lib/nginx/cache/private \
  384. /var/cache/nginx/proxy_temp
  385. chmod -R 777 /var/cache/nginx
  386. chown root /tmp/nginx
  387. echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf
  388. if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then
  389. echo -e "${CHECKMARK} \e[1;92m Generating dummy SSL Certificate... \e[0m"
  390. openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/O=Nginx Proxy Manager/OU=Dummy Certificate/CN=localhost" -keyout /data/nginx/dummykey.pem -out /data/nginx/dummycert.pem &>/dev/null
  391. fi
  392. mkdir -p /app/global /app/frontend/images
  393. cp -r backend/* /app
  394. cp -r global/* /app/global
  395. msg_ok "Setup Enviroment"
  396. msg_info "Building Frontend"
  397. cd ./frontend
  398. export NODE_ENV=development
  399. yarn install --network-timeout=30000 &>/dev/null
  400. yarn build &>/dev/null
  401. cp -r dist/* /app/frontend
  402. cp -r app-images/* /app/frontend/images
  403. msg_ok "Built Frontend"
  404. msg_info "Initializing Backend"
  405. rm -rf /app/config/default.json &>/dev/null
  406. if [ ! -f /app/config/production.json ]; then
  407. cat <<'EOF' >/app/config/production.json
  408. {
  409. "database": {
  410. "engine": "knex-native",
  411. "knex": {
  412. "client": "sqlite3",
  413. "connection": {
  414. "filename": "/data/database.sqlite"
  415. }
  416. }
  417. }
  418. }
  419. EOF
  420. fi
  421. cd /app
  422. export NODE_ENV=development
  423. yarn install --network-timeout=30000 &>/dev/null
  424. msg_ok "Initialized Backend"
  425. msg_info "Starting Services"
  426. systemctl enable npm &>/dev/null
  427. systemctl start openresty
  428. systemctl start npm
  429. msg_ok "Started Services"
  430. msg_info "Cleaning up"
  431. rm -rf nginx-proxy-manager-${RELEASE}
  432. msg_ok "Cleaned"
  433. msg_ok "Update Successfull"
  434. exit
  435. }
  436. clear
  437. ARCH_CHECK
  438. if ! command -v pveversion >/dev/null 2>&1; then update_script; else install_script; fi
  439. if [ "$VERB" == "yes" ]; then set -x; fi
  440. if [ "$CT_TYPE" == "1" ]; then
  441. FEATURES="nesting=1,keyctl=1"
  442. else
  443. FEATURES="nesting=1"
  444. fi
  445. TEMP_DIR=$(mktemp -d)
  446. pushd $TEMP_DIR >/dev/null
  447. export DISABLEIPV6=$DISABLEIP6
  448. export VERBOSE=$VERB
  449. export SSH_ROOT=${SSH}
  450. export CTID=$CT_ID
  451. export PCT_OSTYPE=$var_os
  452. export PCT_OSVERSION=$var_version
  453. export PCT_DISK_SIZE=$DISK_SIZE
  454. export PCT_OPTIONS="
  455. -features $FEATURES
  456. -hostname $HN
  457. $SD
  458. $NS
  459. -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU
  460. -onboot 1
  461. -cores $CORE_COUNT
  462. -memory $RAM_SIZE
  463. -unprivileged $CT_TYPE
  464. $PW
  465. "
  466. bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
  467. msg_info "Starting LXC Container"
  468. pct start $CTID
  469. msg_ok "Started LXC Container"
  470. lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
  471. IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
  472. pct set $CTID -description "# ${APP} LXC
  473. ### https://tteck.github.io/Proxmox/
  474. <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-red' /></a>"
  475. msg_ok "Completed Successfully!\n"
  476. echo -e "${APP} should be reachable by going to the following URL.
  477. ${BL}http://${IP}:81${CL} \n"