build.func 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. variables() {
  2. NSAPP=$(echo ${APP,,} | tr -d ' ')
  3. var_install="${NSAPP}-install"
  4. INTEGER='^[0-9]+([.][0-9]+)?$'
  5. }
  6. color() {
  7. YW=$(echo "\033[33m")
  8. BL=$(echo "\033[36m")
  9. RD=$(echo "\033[01;31m")
  10. BGN=$(echo "\033[4;92m")
  11. GN=$(echo "\033[1;92m")
  12. DGN=$(echo "\033[32m")
  13. CL=$(echo "\033[m")
  14. CM="${GN}✓${CL}"
  15. CROSS="${RD}✗${CL}"
  16. BFR="\\r\\033[K"
  17. HOLD="-"
  18. }
  19. catch_errors() {
  20. set -Eeuo pipefail
  21. trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
  22. }
  23. error_handler() {
  24. local exit_code="$?"
  25. local line_number="$1"
  26. local command="$2"
  27. local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
  28. echo -e "\n$error_message\n"
  29. }
  30. msg_info() {
  31. local msg="$1"
  32. echo -ne " ${HOLD} ${YW}${msg}..."
  33. }
  34. msg_ok() {
  35. local msg="$1"
  36. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  37. }
  38. msg_error() {
  39. local msg="$1"
  40. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  41. }
  42. pve_check() {
  43. if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then
  44. echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported"
  45. echo -e "Requires PVE Version 7.0 or higher"
  46. echo -e "Exiting..."
  47. sleep 2
  48. exit
  49. fi
  50. }
  51. arch_check() {
  52. if [ "$(dpkg --print-architecture)" != "amd64" ]; then
  53. echo -e "\n ${CROSS} This script will not work with PiMox! \n"
  54. echo -e "Exiting..."
  55. sleep 2
  56. exit
  57. fi
  58. }
  59. ssh_check() {
  60. if command -v pveversion >/dev/null 2>&1; then
  61. if [ -n "${SSH_CLIENT:+x}" ]; then
  62. if whiptail --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
  63. echo "you've been warned"
  64. else
  65. clear
  66. exit
  67. fi
  68. fi
  69. fi
  70. }
  71. echo_default() {
  72. echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}"
  73. echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
  74. echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
  75. echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}"
  76. echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}"
  77. echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}"
  78. echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}"
  79. echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}"
  80. echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}"
  81. echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
  82. echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}"
  83. echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}"
  84. echo -e "${DGN}Disable IPv6: ${BGN}No${CL}"
  85. echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
  86. echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}"
  87. echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}"
  88. echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}"
  89. echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}"
  90. echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}"
  91. if [[ "$APP" == "Docker" || "$APP" == "Umbrel" || "$APP" == "CasaOS" || "$APP" == "Home Assistant" ]]; then
  92. echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}"
  93. fi
  94. echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
  95. echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
  96. }
  97. exit-script() {
  98. clear
  99. echo -e "⚠ User exited script \n"
  100. exit
  101. }
  102. advanced_settings() {
  103. whiptail --msgbox --title "Here is an instructional tip:" "To make a selection, use the Spacebar." 8 58
  104. whiptail --msgbox --title "Default distribution for $APP" "${var_os} \n${var_version} \n" 8 58
  105. if [ "$var_os" != "alpine" ]; then
  106. var_os=""
  107. while [ -z "$var_os" ]; do
  108. if var_os=$(whiptail --title "DISTRIBUTION" --radiolist "Choose Distribution:" 10 58 2 \
  109. "debian" "" OFF \
  110. "ubuntu" "" OFF \
  111. 3>&1 1>&2 2>&3); then
  112. if [ -n "$var_os" ]; then
  113. echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}"
  114. fi
  115. else
  116. exit-script
  117. fi
  118. done
  119. fi
  120. if [ "$var_os" == "debian" ]; then
  121. var_version="11"
  122. echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
  123. fi
  124. if [ "$var_os" == "ubuntu" ]; then
  125. var_version=""
  126. while [ -z "$var_version" ]; do
  127. if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \
  128. "20.04" "Focal" OFF \
  129. "22.04" "Jammy" OFF \
  130. "22.10" "Kinetic" OFF \
  131. 3>&1 1>&2 2>&3); then
  132. if [ -n "$var_version" ]; then
  133. echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}"
  134. fi
  135. else
  136. exit-script
  137. fi
  138. done
  139. fi
  140. CT_TYPE=""
  141. while [ -z "$CT_TYPE" ]; do
  142. if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \
  143. "1" "Unprivileged" OFF \
  144. "0" "Privileged" OFF \
  145. 3>&1 1>&2 2>&3); then
  146. if [ -n "$CT_TYPE" ]; then
  147. echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}"
  148. fi
  149. else
  150. exit-script
  151. fi
  152. done
  153. if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then
  154. if [ -z $PW1 ]; then
  155. PW1="Automatic Login"
  156. PW=" "
  157. else
  158. PW="-password $PW1"
  159. fi
  160. echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}"
  161. else
  162. exit-script
  163. fi
  164. if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then
  165. if [ -z "$CT_ID" ]; then
  166. CT_ID="$NEXTID"
  167. echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"
  168. else
  169. echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}"
  170. fi
  171. else
  172. exit
  173. fi
  174. if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then
  175. if [ -z "$CT_NAME" ]; then
  176. HN="$NSAPP"
  177. else
  178. HN=$(echo ${CT_NAME,,} | tr -d ' ')
  179. fi
  180. echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
  181. else
  182. exit-script
  183. fi
  184. if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then
  185. if [ -z "$DISK_SIZE" ]; then
  186. DISK_SIZE="$var_disk"
  187. echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
  188. else
  189. if ! [[ $DISK_SIZE =~ $INTEGER ]]; then
  190. echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}"
  191. advanced_settings
  192. fi
  193. echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"
  194. fi
  195. else
  196. exit-script
  197. fi
  198. if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then
  199. if [ -z "$CORE_COUNT" ]; then
  200. CORE_COUNT="$var_cpu"
  201. echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
  202. else
  203. echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
  204. fi
  205. else
  206. exit-script
  207. fi
  208. if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then
  209. if [ -z "$RAM_SIZE" ]; then
  210. RAM_SIZE="$var_ram"
  211. echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
  212. else
  213. echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
  214. fi
  215. else
  216. exit-script
  217. fi
  218. if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then
  219. if [ -z "$BRG" ]; then
  220. BRG="vmbr0"
  221. echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
  222. else
  223. echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
  224. fi
  225. else
  226. exit-script
  227. fi
  228. while true; do
  229. NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address (/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3)
  230. exit_status=$?
  231. if [ $exit_status -eq 0 ]; then
  232. if [ "$NET" = "dhcp" ]; then
  233. echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
  234. break
  235. else
  236. if [[ "$NET" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/([0-9]|[1-2][0-9]|3[0-2])$ ]]; then
  237. echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"
  238. break
  239. else
  240. whiptail --msgbox "$NET is an invalid IPv4 CIDR address. Please enter a valid IPv4 CIDR address or 'dhcp'" 8 58
  241. fi
  242. fi
  243. else
  244. exit-script
  245. fi
  246. done
  247. if [ "$NET" != "dhcp" ]; then
  248. while true; do
  249. GATE1=$(whiptail --inputbox "Enter gateway IP address" 8 58 --title "Gateway IP" 3>&1 1>&2 2>&3)
  250. if [ -z "$GATE1" ]; then
  251. whiptail --msgbox "Gateway IP address cannot be empty" 8 58
  252. elif [[ ! "$GATE1" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
  253. whiptail --msgbox "Invalid IP address format" 8 58
  254. else
  255. GATE=",gw=$GATE1"
  256. echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}"
  257. break
  258. fi
  259. done
  260. else
  261. GATE=""
  262. echo -e "${DGN}Using Gateway IP Address: ${BGN}Default${CL}"
  263. fi
  264. if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then
  265. DISABLEIP6="yes"
  266. else
  267. DISABLEIP6="no"
  268. fi
  269. echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}"
  270. if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then
  271. if [ -z $MTU1 ]; then
  272. MTU1="Default"
  273. MTU=""
  274. else
  275. MTU=",mtu=$MTU1"
  276. fi
  277. echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
  278. else
  279. exit-script
  280. fi
  281. if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then
  282. if [ -z $SD ]; then
  283. SX=Host
  284. SD=""
  285. else
  286. SX=$SD
  287. SD="-searchdomain=$SD"
  288. fi
  289. echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}"
  290. else
  291. exit-script
  292. fi
  293. if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then
  294. if [ -z $NX ]; then
  295. NX=Host
  296. NS=""
  297. else
  298. NS="-nameserver=$NX"
  299. fi
  300. echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}"
  301. else
  302. exit-script
  303. fi
  304. if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
  305. if [ -z $MAC1 ]; then
  306. MAC1="Default"
  307. MAC=""
  308. else
  309. MAC=",hwaddr=$MAC1"
  310. echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"
  311. fi
  312. else
  313. exit-script
  314. fi
  315. if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then
  316. if [ -z $VLAN1 ]; then
  317. VLAN1="Default"
  318. VLAN=""
  319. else
  320. VLAN=",tag=$VLAN1"
  321. fi
  322. echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
  323. else
  324. exit-script
  325. fi
  326. if [[ "$PW" == -password* ]]; then
  327. if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then
  328. SSH="yes"
  329. else
  330. SSH="no"
  331. fi
  332. echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}"
  333. else
  334. SSH="no"
  335. echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}"
  336. fi
  337. if [[ "$APP" == "Docker" || "$APP" == "Umbrel" || "$APP" == "CasaOS" || "$APP" == "Home Assistant" ]]; then
  338. if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then
  339. FUSE="yes"
  340. else
  341. FUSE="no"
  342. fi
  343. echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}"
  344. fi
  345. if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
  346. VERB="yes"
  347. else
  348. VERB="no"
  349. fi
  350. echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}"
  351. if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then
  352. echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
  353. else
  354. clear
  355. header_info
  356. echo -e "${RD}Using Advanced Settings${CL}"
  357. advanced_settings
  358. fi
  359. }
  360. install_script() {
  361. ssh_check
  362. arch_check
  363. pve_check
  364. if systemctl is-active -q ping-instances.service; then
  365. systemctl stop ping-instances.service
  366. fi
  367. NEXTID=$(pvesh get /cluster/nextid)
  368. timezone=$(cat /etc/timezone)
  369. header_info
  370. if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
  371. header_info
  372. echo -e "${BL}Using Default Settings${CL}"
  373. default_settings
  374. else
  375. header_info
  376. echo -e "${RD}Using Advanced Settings${CL}"
  377. advanced_settings
  378. fi
  379. }
  380. start() {
  381. if command -v pveversion >/dev/null 2>&1; then
  382. if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
  383. clear
  384. echo -e "⚠ User exited script \n"
  385. exit
  386. fi
  387. install_script
  388. fi
  389. if ! command -v pveversion >/dev/null 2>&1; then
  390. if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then
  391. clear
  392. echo -e "⚠ User exited script \n"
  393. exit
  394. fi
  395. update_script
  396. fi
  397. }
  398. build_container() {
  399. if [ "$VERB" == "yes" ]; then set -x; fi
  400. if [[ "$APP" == "Docker" || "$APP" == "Umbrel" || "$APP" == "CasaOS" || "$APP" == "Home Assistant" ]]; then
  401. if [ "$FUSE" == "yes" ]; then
  402. FEATURES="fuse=1,keyctl=1,nesting=1"
  403. else
  404. FEATURES="keyctl=1,nesting=1"
  405. fi
  406. fi
  407. if [[ "$APP" != "Docker" && "$APP" != "Umbrel" && "$APP" != "CasaOS" && "$APP" != "Home Assistant" ]]; then
  408. if [ "$CT_TYPE" == "1" ]; then
  409. FEATURES="keyctl=1,nesting=1"
  410. else
  411. FEATURES="nesting=1"
  412. fi
  413. fi
  414. TEMP_DIR=$(mktemp -d)
  415. pushd $TEMP_DIR >/dev/null
  416. if [ "$var_os" == "alpine" ]; then
  417. export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine-install.func)"
  418. else
  419. export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/install.func)"
  420. fi
  421. export tz="$timezone"
  422. if [[ "$APP" == "Docker" || "$APP" == "Umbrel" || "$APP" == "CasaOS" || "$APP" == "Home Assistant" ]]; then
  423. export ST="$FUSE"
  424. fi
  425. export DISABLEIPV6="$DISABLEIP6"
  426. export APPLICATION="$APP"
  427. export VERBOSE="$VERB"
  428. export SSH_ROOT="${SSH}"
  429. export CTID="$CT_ID"
  430. export PCT_OSTYPE="$var_os"
  431. export PCT_OSVERSION="$var_version"
  432. export PCT_DISK_SIZE="$DISK_SIZE"
  433. export PCT_OPTIONS="
  434. -features $FEATURES
  435. -hostname $HN
  436. -tags proxmox-helper-scripts
  437. $SD
  438. $NS
  439. -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU
  440. -onboot 1
  441. -cores $CORE_COUNT
  442. -memory $RAM_SIZE
  443. -unprivileged $CT_TYPE
  444. $PW
  445. "
  446. bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
  447. LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
  448. if [ "$CT_TYPE" == "0" ]; then
  449. if [[ "$APP" != "Emby" && "$APP" != "Jellyfin" && "$APP" != "Plex" ]]; then
  450. cat <<EOF >>$LXC_CONFIG
  451. lxc.cgroup2.devices.allow: a
  452. lxc.cap.drop:
  453. lxc.cgroup2.devices.allow: c 188:* rwm
  454. lxc.cgroup2.devices.allow: c 189:* rwm
  455. lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir
  456. lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file
  457. lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file
  458. lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file
  459. lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file
  460. EOF
  461. fi
  462. fi
  463. if [ "$CT_TYPE" == "0" ]; then
  464. if [[ "$APP" == "Emby" || "$APP" == "Jellyfin" || "$APP" == "Plex" ]]; then
  465. cat <<EOF >>$LXC_CONFIG
  466. lxc.cgroup2.devices.allow: a
  467. lxc.cap.drop:
  468. lxc.cgroup2.devices.allow: c 226:0 rwm
  469. lxc.cgroup2.devices.allow: c 226:128 rwm
  470. lxc.cgroup2.devices.allow: c 29:0 rwm
  471. lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
  472. lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
  473. lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
  474. EOF
  475. fi
  476. fi
  477. msg_info "Starting LXC Container"
  478. pct start "$CTID"
  479. msg_ok "Started LXC Container"
  480. if [ "$var_os" == "alpine" ]; then
  481. sleep 2
  482. pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
  483. fi
  484. lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
  485. }
  486. description() {
  487. IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
  488. pct set "$CTID" -description "# ${APP} LXC
  489. ### https://tteck.github.io/Proxmox/
  490. <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-red' /></a>"
  491. if [[ -f /etc/systemd/system/ping-instances.service ]]; then
  492. systemctl start ping-instances.service
  493. fi
  494. }