first commit
This commit is contained in:
46
scripts/build.sh
Executable file
46
scripts/build.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="1.0.0"
|
||||
MODULE_NAME="oc_telegram_shop"
|
||||
CURRENT_DIR="$(dirname "$0")"
|
||||
|
||||
echo "Current dir: ${CURRENT_DIR}"
|
||||
node -v
|
||||
npm -v
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}🔨 Starting build process...${NC}"
|
||||
|
||||
echo -e "${BLUE}Build frontend...${NC}"
|
||||
rm -rf /app/module/oc_telegram_shop/upload/admin/view/javascript
|
||||
rm -rf /app/module/oc_telegram_shop/upload/admin/view/integration.js
|
||||
cd /app/frontend
|
||||
npm install
|
||||
NODE_ENV=production npm run build
|
||||
rm -rf /app/module/oc_telegram_shop/upload/admin/view/javascript/oc_telegram_shop/.vite
|
||||
rm -rf /app/module/oc_telegram_shop/upload/admin/view/javascript/oc_telegram_shop/oc_telegram_shop.js.map
|
||||
rm -rf /app/module/oc_telegram_shop/upload/admin/view/javascript/oc_telegram_shop/favicon.ico
|
||||
|
||||
echo -e "${BLUE}📦 Packaging into .ocmod.zip...${NC}"
|
||||
cd /app/module/oc_telegram_shop
|
||||
zip -rqq "${MODULE_NAME}.ocmod.zip" .
|
||||
mv "${MODULE_NAME}.ocmod.zip" /build
|
||||
|
||||
FINAL_FILE="/build/${MODULE_NAME}.ocmod.zip"
|
||||
|
||||
if [ -f "$FINAL_FILE" ]; then
|
||||
FILE_SIZE=$(du -h "$FINAL_FILE" | cut -f1)
|
||||
echo -e "${GREEN}✅ Build completed successfully!${NC}"
|
||||
echo -e "${GREEN}🎉 Created: $FINAL_FILE ($FILE_SIZE)${NC}"
|
||||
else
|
||||
echo "❌ Error: Final build file not found: $FINAL_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}🎯 Build artifact ready for installation!${NC}"
|
||||
35
scripts/download_oc_store.sh
Executable file
35
scripts/download_oc_store.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The script downloads and unzip ocStore.
|
||||
# Should be executed from the project root folder.
|
||||
|
||||
set -e
|
||||
|
||||
OCSTORE_VERSION=v3.0.3.7
|
||||
CACHE_DIR=.cache
|
||||
|
||||
echo "👽 Downloading ocStore ${OCSTORE_VERSION}..."
|
||||
|
||||
DOWNLOAD_URL="https://github.com/ocStore/ocStore/archive/refs/tags/$OCSTORE_VERSION.zip"
|
||||
|
||||
FILE_PATH="$CACHE_DIR/$OCSTORE_VERSION.zip"
|
||||
|
||||
if [ ! -f "$FILE_PATH" ]; then
|
||||
mkdir -p "$CACHE_DIR"
|
||||
wget -P "$CACHE_DIR" "$DOWNLOAD_URL"
|
||||
else
|
||||
echo "😎 Get file from cache: $FILE_PATH"
|
||||
fi
|
||||
|
||||
echo "🗃 Unzipping..."
|
||||
rm -rf src/*
|
||||
|
||||
unzip -q "$FILE_PATH" -d ./src
|
||||
SOURCE_DIR=src/ocStore-${OCSTORE_VERSION//v/}
|
||||
|
||||
rsync -a $SOURCE_DIR/* ./src
|
||||
rm -rf $SOURCE_DIR
|
||||
|
||||
chmod -R 775 src
|
||||
|
||||
echo "✅ Completed."
|
||||
42
scripts/install_ocstore.sh
Executable file
42
scripts/install_ocstore.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The script install ocStore.
|
||||
# Should be executed from the project root folder.
|
||||
|
||||
echo "Setup ocStore..."
|
||||
|
||||
set -e
|
||||
|
||||
docker compose down -v && docker compose up -d web mysql --remove-orphans
|
||||
|
||||
bash ./scripts/wait_for_containers.sh
|
||||
bash ./scripts/wait_for_mysql.sh
|
||||
|
||||
echo "Install composer dependencies..."
|
||||
docker compose exec web bash -c "cd /web; composer update"
|
||||
|
||||
docker compose exec web bash -c '\
|
||||
cd /web/upload/install; \
|
||||
php cli_install.php install \
|
||||
--db_hostname mysql \
|
||||
--db_username root \
|
||||
--db_password secret \
|
||||
--db_database ocstore3 \
|
||||
--db_driver mysqli \
|
||||
--db_port 3306 \
|
||||
--username admin \
|
||||
--password admin \
|
||||
--email youremail@example.com \
|
||||
--http_server http://localhost:8000/; exit $?'
|
||||
|
||||
docker compose exec web bash -c "cd /web; composer update"
|
||||
echo "Moving storage folder outside the system."
|
||||
mv src/upload/system/storage src/
|
||||
|
||||
docker compose exec web bash -c "\
|
||||
sed -i \"s/DIR_SYSTEM \. 'storage\/'/'\/web\/storage\/'/g\" /web/upload/config.php
|
||||
sed -i \"s/DIR_SYSTEM \. 'storage\/'/'\/web\/storage\/'/g\" /web/upload/admin/config.php"
|
||||
|
||||
rm -rf src/upload/install
|
||||
|
||||
echo "OcStore successfully installed."
|
||||
40
scripts/link.php
Normal file
40
scripts/link.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$module = 'oc_layout_pro';
|
||||
|
||||
$basePath = dirname(__DIR__) . '/';
|
||||
|
||||
if ($basePath === '//') {
|
||||
$basePath = '/';
|
||||
}
|
||||
|
||||
$modulesPath = $basePath . 'module/';
|
||||
$modulePath = $modulesPath . $module . '/upload/';
|
||||
|
||||
$files = [];
|
||||
|
||||
$iterator = new RecursiveDirectoryIterator($modulePath);
|
||||
$recursiveIterator = new RecursiveIteratorIterator($iterator);
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($recursiveIterator as $file) {
|
||||
if ($file->isFile() && fnmatch($pattern = '*', $file->getFilename())) {
|
||||
$files[] = $file->getRealPath();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$link = $basePath . 'web/upload/' . str_replace($modulePath, '', $file);
|
||||
|
||||
if (! is_dir(dirname($link))) {
|
||||
if (!mkdir($concurrentDirectory = dirname($link), 0775, true) && !is_dir($concurrentDirectory)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
|
||||
}
|
||||
}
|
||||
|
||||
echo sprintf('%s => %s', $file, $link) . PHP_EOL;
|
||||
|
||||
@unlink($link);
|
||||
symlink($file, $link);
|
||||
chmod($link, 0777);
|
||||
}
|
||||
28
scripts/wait_for_containers.sh
Executable file
28
scripts/wait_for_containers.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
SERVICES=("web" "mysql")
|
||||
|
||||
function check_containers {
|
||||
for service in "${SERVICES[@]}"; do
|
||||
if ! docker compose ps $service | grep "Up" > /dev/null; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "Waiting for docker containers..."
|
||||
|
||||
MAX_WAIT_TIME=60
|
||||
WAIT_TIME=0
|
||||
|
||||
while ! check_containers; do
|
||||
if [ $WAIT_TIME -ge $MAX_WAIT_TIME ]; then
|
||||
echo "Containers have not started within $MAX_WAIT_TIME seconds. Exit."
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
WAIT_TIME=$((WAIT_TIME + 1))
|
||||
done
|
||||
|
||||
echo "All docker containers executed."
|
||||
24
scripts/wait_for_mysql.sh
Normal file
24
scripts/wait_for_mysql.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
MYSQL_SERVICE="mysql"
|
||||
|
||||
function check_mysql {
|
||||
docker compose exec $MYSQL_SERVICE mysqladmin ping --silent
|
||||
}
|
||||
|
||||
echo "Waiting for MySQL..."
|
||||
|
||||
MAX_WAIT_TIME=60
|
||||
WAIT_TIME=0
|
||||
|
||||
while ! check_mysql; do
|
||||
if [ $WAIT_TIME -ge $MAX_WAIT_TIME ]; then
|
||||
echo "MySQL has not been available for $MAX_WAIT_TIME secods. Exit."
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
WAIT_TIME=$((WAIT_TIME + 1))
|
||||
done
|
||||
|
||||
sleep 5
|
||||
echo "MySQL ready."
|
||||
Reference in New Issue
Block a user