#!/bin/bash

source debian/vars.sh

# Clean the build root first
rm -rf $buildroot
# Installing directories
install -d -m 755 $buildroot/usr
install -d -m 755 $buildroot/usr/local
install -d -m 755 $buildroot/usr/local/cpanel
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/API
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Admin
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Config
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj/Driver
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Server
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Server/WebSocket
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Server/WebSocket/cpanel
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Sitejet
install -d -m 755 $buildroot/usr/local/cpanel/Whostmgr
install -d -m 755 $buildroot/usr/local/cpanel/Whostmgr/API
install -d -m 755 $buildroot/usr/local/cpanel/Whostmgr/API/1
install -d -m 755 $buildroot/usr/local/cpanel/base
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners/sitejet
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners/sitejet/banner-ai
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet
install -d -m 755 $buildroot/usr/local/cpanel/t
install -d -m 755 $buildroot/usr/local/cpanel/t/medium
install -d -m 755 $buildroot/var
install -d -m 755 $buildroot/var/cpanel
install -d -m 755 $buildroot/var/cpanel/feature-flags
install -d -m 755 $buildroot/var/cpanel/plugins
install -d -m 755 $buildroot/var/cpanel/plugins/sitejet
install -d -m 755 $buildroot/var/cpanel/plugins/sitejet/locale
install -d -m 755 $buildroot/var/cpanel/plugins/sitejet/menu
install -d -m 755 $buildroot/var/cpanel/plugins/sitejet_banner-ai
# Installing source files
install -D -m 644 $SOURCE5 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-add_api_token.openapi.yaml
install -D -m 644 $SOURCE6 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-can_create_domains.openapi.yaml
install -D -m 644 $SOURCE7 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-create_account.openapi.yaml
install -D -m 644 $SOURCE8 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-create_restore_point.openapi.yaml
install -D -m 644 $SOURCE9 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-create_website.openapi.yaml
install -D -m 644 $SOURCE10 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-disk_quota_check.openapi.yaml
install -D -m 644 $SOURCE11 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_all_sites_metadata.openapi.yaml
install -D -m 644 $SOURCE12 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_all_user_sitejet_info.openapi.yaml
install -D -m 644 $SOURCE13 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_api_token.openapi.yaml
install -D -m 644 $SOURCE14 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_preview_url.openapi.yaml
install -D -m 644 $SOURCE15 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_sitebuilder_domain_statuses.openapi.yaml
install -D -m 644 $SOURCE16 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_sso_link.openapi.yaml
install -D -m 644 $SOURCE17 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_templates.openapi.yaml
install -D -m 644 $SOURCE18 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-get_user_site_metadata.openapi.yaml
install -D -m 644 $SOURCE19 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-poll_publish.openapi.yaml
install -D -m 644 $SOURCE20 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-publish.openapi.yaml
install -D -m 644 $SOURCE21 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-restore_document_root.openapi.yaml
install -D -m 644 $SOURCE22 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-set_template.openapi.yaml
install -D -m 644 $SOURCE23 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet-start_publish.openapi.yaml
install -D -m 644 $SOURCE24 $buildroot/usr/local/cpanel/Cpanel/API/Sitejet.pm
install -D -m 644 $SOURCE25 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/sitejet.pm
install -D -m 644 $SOURCE26 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Sitejet.pm
install -D -m 644 $SOURCE27 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Sitejet/META.pm
install -D -m 644 $SOURCE28 $buildroot/usr/local/cpanel/Cpanel/Exception/Sitejet/API.pm
install -D -m 644 $SOURCE29 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/cpanel/tools/SitejetBannerAI.pm
install -D -m 644 $SOURCE30 $buildroot/usr/local/cpanel/Cpanel/Server/WebSocket/cpanel/LogStreamer.pm
install -D -m 644 $SOURCE31 $buildroot/usr/local/cpanel/Cpanel/Sitejet/Beta/Setup.pm
install -D -m 644 $SOURCE32 $buildroot/usr/local/cpanel/Cpanel/Sitejet/Connector.pm
install -D -m 644 $SOURCE33 $buildroot/usr/local/cpanel/Cpanel/Sitejet/Hooks/ChangeDomains.pm
install -D -m 644 $SOURCE34 $buildroot/usr/local/cpanel/Cpanel/Sitejet/MoveWebsite.pm
install -D -m 644 $SOURCE35 $buildroot/usr/local/cpanel/Cpanel/Sitejet/Publish.pm
install -D -m 644 $SOURCE36 $buildroot/usr/local/cpanel/Cpanel/Template/Plugin/Sitejet.pm
install -D -m 644 $SOURCE37 $buildroot/usr/local/cpanel/Whostmgr/API/1/Sitejet-get_commerce.openapi.yaml
install -D -m 644 $SOURCE38 $buildroot/usr/local/cpanel/Whostmgr/API/1/Sitejet-get_ecommerce.openapi.yaml
install -D -m 644 $SOURCE39 $buildroot/usr/local/cpanel/Whostmgr/API/1/Sitejet-set_commerce.openapi.yaml
install -D -m 644 $SOURCE40 $buildroot/usr/local/cpanel/Whostmgr/API/1/Sitejet-set_ecommerce.openapi.yaml
install -D -m 644 $SOURCE41 $buildroot/usr/local/cpanel/Whostmgr/API/1/Sitejet.pm
install -D -m 644 $SOURCE42 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners/sitejet/banner-ai/assets/tools-banner-bg.png
install -D -m 644 $SOURCE43 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners/sitejet/banner-ai/cp-sitejet-banner-ai.min.js
install -D -m 644 $SOURCE44 $buildroot/usr/local/cpanel/base/frontend/jupiter/plugin_banners/sitejet/banner-ai/sitejet_banner_ai.tt
install -D -m 644 $SOURCE45 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet-domains/index.html.tt
install -D -m 644 $SOURCE46 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet-domains/sitejet-api.min.js
install -D -m 644 $SOURCE47 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/3rdpartylicenses.txt
install -D -m 644 $SOURCE48 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/assets/Site_Builder_Dark.svg
install -D -m 644 $SOURCE49 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/assets/Site_Builder_Light.svg
install -D -m 644 $SOURCE50 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/assets/no-image.svg
install -D -m 644 $SOURCE51 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/index.html.tt
install -D -m 644 $SOURCE52 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/jupiter-styles-main-rtl.7862efc34a8366cd.css
install -D -m 644 $SOURCE53 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/jupiter-styles-main.68ae2510740fb843.css
install -D -m 644 $SOURCE54 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/main.3af9a323acb6c4b1.js
install -D -m 644 $SOURCE55 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/polyfills.fe2a85d529afbbf9.js
install -D -m 644 $SOURCE56 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/runtime.d27c0ba731149486.js
install -D -m 644 $SOURCE57 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/styles.40f9dc8b1a33a0bb.css
install -D -m 644 $SOURCE58 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/vendor-89d5c698.7ec1d195a9aa4b2c.js
install -D -m 644 $SOURCE59 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/vendor-c0d76f48.495336d4827a3b34.js
install -D -m 644 $SOURCE60 $buildroot/usr/local/cpanel/base/frontend/jupiter/sitejet/webpack.shim.html
install -D -m 644 $SOURCE61 $buildroot/usr/local/cpanel/t/medium/Cpanel-API-Sitejet_plugin.t
install -D -m 644 $SOURCE62 $buildroot/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-sitejet_plugin.t
install -D -m 644 $SOURCE63 $buildroot/usr/local/cpanel/t/medium/Cpanel-Config-ConfigObj-Driver-Sitejet-META_plugin.t
install -D -m 644 $SOURCE64 $buildroot/usr/local/cpanel/t/medium/Cpanel-Config-ConfigObj-Driver-Sitejet_plugin.t
install -D -m 644 $SOURCE65 $buildroot/usr/local/cpanel/t/medium/Cpanel-Exception-Sitejet-API_sitejet_plugin.t
install -D -m 644 $SOURCE66 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-cpanel-tools-SitejetBannerAI_plugin.t
install -D -m 644 $SOURCE67 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-Beta-Setup.t
install -D -m 644 $SOURCE68 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-Connector_sitejet_plugin.t
install -D -m 644 $SOURCE69 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-Hooks-ChangeDomains.t
install -D -m 644 $SOURCE70 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-MoveWebsite_plugin.t
install -D -m 644 $SOURCE71 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-MoveWebsite_update_assets.t
install -D -m 644 $SOURCE72 $buildroot/usr/local/cpanel/t/medium/Cpanel-Sitejet-Publish_sitejet_plugin.t
install -D -m 644 $SOURCE73 $buildroot/usr/local/cpanel/t/medium/Cpanel-Template-Plugin-Sitejet.t
install -D -m 644 $SOURCE74 $buildroot/usr/local/cpanel/t/medium/Whostmgr-API-1-Sitejet_plugin.t
install -D -m 644 $SOURCE75 $buildroot/usr/local/cpanel/t/medium/retry_domain_migration_sitejet_plugin.t
install -D -m 644 $SOURCE76 $buildroot/usr/local/cpanel/t/qa/playwright/classes/plugins/sitejet/banner_ai.ts
install -D -m 644 $SOURCE77 $buildroot/usr/local/cpanel/t/qa/playwright/fixtures/plugins/sitejet/sitejet_banner_ai.ts
install -D -m 644 $SOURCE78 $buildroot/usr/local/cpanel/t/qa/playwright/page/plugins/sitejet/sitejet_banner_ai.ts
install -D -m 644 $SOURCE79 $buildroot/usr/local/cpanel/t/qa/playwright/specs/plugins/sitejet/cpanel-sitejet_banner_ai-companyid.spec.ts
install -D -m 644 $SOURCE80 $buildroot/usr/local/cpanel/t/qa/playwright/specs/plugins/sitejet/cpanel-sitejet_banner_ai.spec.ts
install -D -m 644 $SOURCE81 $buildroot/var/cpanel/feature-flags/cpanel.sitejet.plugin.installed
install -D -m 644 $SOURCE82 $buildroot/var/cpanel/plugins/sitejet/README.md
install -D -m 644 $SOURCE83 $buildroot/var/cpanel/plugins/sitejet/config.yaml
install -D -m 644 $SOURCE84 $buildroot/var/cpanel/plugins/sitejet/cpanel-sitejet-plugin.svg
install -D -m 644 $SOURCE85 $buildroot/var/cpanel/plugins/sitejet/extra_strings
install -D -m 644 $SOURCE86 $buildroot/var/cpanel/plugins/sitejet/features/11.110_disable_sitejet.jsonc
install -D -m 644 $SOURCE87 $buildroot/var/cpanel/plugins/sitejet/features/11.110_enable_sitejet.jsonc
install -D -m 644 $SOURCE88 $buildroot/var/cpanel/plugins/sitejet/features/11.116_enable_sitejet.jsonc
install -D -m 644 $SOURCE89 $buildroot/var/cpanel/plugins/sitejet/install.json
install -D -m 644 $SOURCE90 $buildroot/var/cpanel/plugins/sitejet/js_files_with_mt_calls
install -D -m 644 $SOURCE91 $buildroot/var/cpanel/plugins/sitejet/locale/ar.yaml
install -D -m 644 $SOURCE92 $buildroot/var/cpanel/plugins/sitejet/locale/de.yaml
install -D -m 644 $SOURCE93 $buildroot/var/cpanel/plugins/sitejet/locale/es.yaml
install -D -m 644 $SOURCE94 $buildroot/var/cpanel/plugins/sitejet/locale/es_419.yaml
install -D -m 644 $SOURCE95 $buildroot/var/cpanel/plugins/sitejet/locale/es_es.yaml
install -D -m 644 $SOURCE96 $buildroot/var/cpanel/plugins/sitejet/locale/fr.yaml
install -D -m 644 $SOURCE97 $buildroot/var/cpanel/plugins/sitejet/locale/id.yaml
install -D -m 644 $SOURCE98 $buildroot/var/cpanel/plugins/sitejet/locale/ja.yaml
install -D -m 644 $SOURCE99 $buildroot/var/cpanel/plugins/sitejet/locale/pt.yaml
install -D -m 644 $SOURCE100 $buildroot/var/cpanel/plugins/sitejet/locale/pt_br.yaml
install -D -m 644 $SOURCE101 $buildroot/var/cpanel/plugins/sitejet/locale/tr.yaml
install -D -m 644 $SOURCE102 $buildroot/var/cpanel/plugins/sitejet/menu/LeftMenu.default.yaml
install -D -m 644 $SOURCE103 $buildroot/var/cpanel/plugins/sitejet/menu/WelcomeModal.yaml
install -D -m 644 $SOURCE104 $buildroot/var/cpanel/plugins/sitejet/resources/api.php.tmpl
install -D -m 644 $SOURCE105 $buildroot/var/cpanel/plugins/sitejet/resources/flags.tar.gz
install -D -m 750 $SOURCE106 $buildroot/var/cpanel/plugins/sitejet/scripts/move_config_to_dot_cpanel.pl
install -D -m 700 $SOURCE107 $buildroot/var/cpanel/plugins/sitejet/scripts/retry_domain_migration.pl
install -D -m 644 $SOURCE108 $buildroot/var/cpanel/plugins/sitejet_banner-ai/sitejet_banner_ai.json
echo "Tree for buildroot: $buildroot"
tree $buildroot
