#!/bin/bash

source debian/vars.sh

# Clean the build root first
rm -rf $buildroot
# Installing directories
install -d -m 755 $buildroot/etc
install -d -m 755 $buildroot/etc/systemd
install -d -m 755 $buildroot/etc/systemd/system
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/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/Config/ConfigObj/Driver/Xovi
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Xovi
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/xovi
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets
install -d -m 755 $buildroot/var
install -d -m 755 $buildroot/var/cpanel
install -d -m 755 $buildroot/var/cpanel/plugins
install -d -m 755 $buildroot/var/cpanel/plugins/xovi
install -d -m 700 $buildroot/var/cpanel/plugins/xovi/.config
install -d -m 755 $buildroot/var/cpanel/plugins/xovi/menu
# Installing source files
install -D -m 644 $SOURCE4 $buildroot/etc/systemd/system/initialize_xovi_plugin.service
install -D -m 644 $SOURCE5 $buildroot/etc/systemd/system/initialize_xovi_plugin.timer
install -D -m 644 $SOURCE6 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/xovi.pm
install -D -m 644 $SOURCE7 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Xovi.pm
install -D -m 644 $SOURCE8 $buildroot/usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Xovi/META.pm
install -D -m 644 $SOURCE9 $buildroot/usr/local/cpanel/Cpanel/Xovi/LifeCycle.pm
install -D -m 644 $SOURCE10 $buildroot/usr/local/cpanel/Cpanel/Xovi/User.pm
install -D -m 644 $SOURCE11 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Inter-DSpl2aj8.woff
install -D -m 644 $SOURCE12 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Inter-Dp62BM7I.ttf
install -D -m 644 $SOURCE13 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Bold-BimIjMzQ.woff2
install -D -m 644 $SOURCE14 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Bold-Clfq1X_x.woff
install -D -m 644 $SOURCE15 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Bold-DrNBRnWz.ttf
install -D -m 644 $SOURCE16 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Light-B1CoQN6d.ttf
install -D -m 644 $SOURCE17 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Light-Bieur7i3.woff
install -D -m 644 $SOURCE18 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Light-QQsonFN9.woff2
install -D -m 644 $SOURCE19 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Regular-9sg7QhcT.woff
install -D -m 644 $SOURCE20 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Regular-B-Jg2Dkm.ttf
install -D -m 644 $SOURCE21 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/Lato-Regular-D_8OfjFW.woff2
install -D -m 644 $SOURCE22 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/index-D2x4pn52.css
install -D -m 644 $SOURCE23 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/index-apv33kjz.js
install -D -m 644 $SOURCE24 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/materialdesignicons-webfont-B7mPwVP_.ttf
install -D -m 644 $SOURCE25 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/materialdesignicons-webfont-CSr8KVlo.eot
install -D -m 644 $SOURCE26 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/materialdesignicons-webfont-Dp5v-WZN.woff2
install -D -m 644 $SOURCE27 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/materialdesignicons-webfont-PXm3-2wK.woff
install -D -m 644 $SOURCE28 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/assets/welcome-page-img-CE2P7m_q.svg
install -D -m 644 $SOURCE29 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/index.html.converted
install -D -m 644 $SOURCE30 $buildroot/usr/local/cpanel/base/frontend/jupiter/xovi/index.html.tt
install -D -m 644 $SOURCE31 $buildroot/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-xovi_plugin.t
install -D -m 644 $SOURCE32 $buildroot/usr/local/cpanel/t/medium/Cpanel-Config-ConfigObj-Driver-Xovi-META_plugin.t
install -D -m 644 $SOURCE33 $buildroot/usr/local/cpanel/t/medium/Cpanel-Config-ConfigObj-Driver-Xovi_plugin.t
install -D -m 644 $SOURCE34 $buildroot/usr/local/cpanel/t/medium/Cpanel-Xovi-LifeCycle_plugin.t
install -D -m 644 $SOURCE35 $buildroot/usr/local/cpanel/t/medium/Cpanel-Xovi-User_plugin.t
install -D -m 600 $SOURCE36 $buildroot/var/cpanel/plugins/xovi/.config/secrets
install -D -m 644 $SOURCE37 $buildroot/var/cpanel/plugins/xovi/README.md
install -D -m 644 $SOURCE38 $buildroot/var/cpanel/plugins/xovi/cpanel-xovi-plugin.svg
install -D -m 644 $SOURCE39 $buildroot/var/cpanel/plugins/xovi/install.json
install -D -m 644 $SOURCE40 $buildroot/var/cpanel/plugins/xovi/install.md
install -D -m 644 $SOURCE41 $buildroot/var/cpanel/plugins/xovi/lifecycle.jsonc
install -D -m 644 $SOURCE42 $buildroot/var/cpanel/plugins/xovi/menu/LeftMenu.default.yaml
install -D -m 644 $SOURCE43 $buildroot/var/cpanel/plugins/xovi/menu/LeftMenu.yaml
echo "Tree for buildroot: $buildroot"
tree $buildroot
