This commit is contained in:
CanbiZ 2025-07-14 12:45:32 +02:00
parent a6fe7b48ba
commit 31d80358c9

View File

@ -7,7 +7,7 @@
# Source: https://github.com/karlomikus/vue-salt-rim # Source: https://github.com/karlomikus/vue-salt-rim
# Source: https://www.meilisearch.com/ # Source: https://www.meilisearch.com/
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color color
verb_ip6 verb_ip6
catch_errors catch_errors
@ -17,39 +17,39 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y \
composer \
redis-server \ redis-server \
npm \
nginx \ nginx \
lsb-release \ lsb-release \
libvips \ libvips
php-{ffi,opcache,redis,zip,pdo-sqlite,bcmath,pdo,curl,dom,fpm} #php-{ffi,opcache,redis,zip,pdo-sqlite,bcmath,pdo,curl,dom,fpm}
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PHP_VERSION=8.3 PHP_MODULE="ffi,opcache,redis,zip,pdo-sqlite,bcmath,pdo,curl,dom,fpm" setup_php
setup_composer
fetch_and_deploy_gh_release "meilisearch" "meilisearch/meilisearch" "binary"
fetch_and_deploy_gh_release "bar-assistant" "karlomikus/bar-assistant" "tarball" "latest" "/opt/bar-assistant"
fetch_and_deploy_gh_release "vue-salt-rim" "karlomikus/vue-salt-rim" "tarball" "latest" "/opt/vue-salt-rim"
msg_info "Configuring PHP" msg_info "Configuring PHP"
PHPVER=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "\n";') PHPVER=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "\n";')
sed -i.bak -E 's/^\s*;?\s*ffi\.enable\s*=.*/ffi.enable=true/' /etc/php/${PHPVER}/fpm/php.ini sed -i.bak -E 's/^\s*;?\s*ffi\.enable\s*=.*/ffi.enable=true/' /etc/php/${PHPVER}/fpm/php.ini
$STD systemctl reload php${PHPVER}-fpm $STD systemctl reload php${PHPVER}-fpm
msg_info "configured PHP" msg_info "configured PHP"
msg_info "Installing MeiliSearch" msg_info "Configure MeiliSearch"
cd /opt
RELEASE_MEILISEARCH=$(curl -s https://api.github.com/repos/meilisearch/meilisearch/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch.deb -o meilisearch.deb
$STD dpkg -i meilisearch.deb
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/latest/config.toml -o /etc/meilisearch.toml curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/latest/config.toml -o /etc/meilisearch.toml
MASTER_KEY=$(openssl rand -base64 12) MASTER_KEY=$(openssl rand -base64 12)
sed -i \ sed -i \
-e 's|^env =.*|env = "production"|' \ -e 's|^env =.*|env = "production"|' \
-e "s|^# master_key =.*|master_key = \"$MASTER_KEY\"|" \ -e "s|^# master_key =.*|master_key = \"$MASTER_KEY\"|" \
-e 's|^db_path =.*|db_path = "/var/lib/meilisearch/data"|' \ -e 's|^db_path =.*|db_path = "/var/lib/meilisearch/data"|' \
-e 's|^dump_dir =.*|dump_dir = "/var/lib/meilisearch/dumps"|' \ -e 's|^dump_dir =.*|dump_dir = "/var/lib/meilisearch/dumps"|' \
-e 's|^snapshot_dir =.*|snapshot_dir = "/var/lib/meilisearch/snapshots"|' \ -e 's|^snapshot_dir =.*|snapshot_dir = "/var/lib/meilisearch/snapshots"|' \
-e 's|^# no_analytics = true|no_analytics = true|' \ -e 's|^# no_analytics = true|no_analytics = true|' \
-e 's|^http_addr =.*|http_addr = "127.0.0.1:7700"|' \ -e 's|^http_addr =.*|http_addr = "127.0.0.1:7700"|' \
/etc/meilisearch.toml /etc/meilisearch.toml
echo "${RELEASE_MEILISEARCH}" >/opt/meilisearch_version.txt msg_ok "Configured MeiliSearch"
msg_ok "Installed MeiliSearch"
msg_info "Creating MeiliSearch service" msg_info "Creating MeiliSearch service"
cat <<EOF >/etc/systemd/system/meilisearch.service cat <<EOF >/etc/systemd/system/meilisearch.service
@ -68,22 +68,17 @@ systemctl enable -q --now meilisearch
msg_ok "Created Service MeiliSearch" msg_ok "Created Service MeiliSearch"
msg_info "Installing Bar Assistant" msg_info "Installing Bar Assistant"
RELEASE_BARASSISTANT=$(curl -s https://api.github.com/repos/karlomikus/bar-assistant/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
cd /opt
curl -fsSL "https://github.com/karlomikus/bar-assistant/archive/refs/tags/v${RELEASE_BARASSISTANT}.zip" -o barassistant.zip
unzip -q barassistant.zip
mv /opt/bar-assistant-${RELEASE_BARASSISTANT}/ /opt/bar-assistant
cd /opt/bar-assistant cd /opt/bar-assistant
cp /opt/bar-assistant/.env.dist /opt/bar-assistant/.env cp /opt/bar-assistant/.env.dist /opt/bar-assistant/.env
MeiliSearch_API_KEY=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"key":"[^"]*"' | head -n 1 | sed 's/"key":"//;s/"//') MeiliSearch_API_KEY=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"key":"[^"]*"' | head -n 1 | sed 's/"key":"//;s/"//')
MeiliSearch_API_KEY_UID=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"uid":"[^"]*"' | head -n 1 | sed 's/"uid":"//;s/"//') MeiliSearch_API_KEY_UID=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"uid":"[^"]*"' | head -n 1 | sed 's/"uid":"//;s/"//')
LOCAL_IP=$(hostname -I | awk '{print $1}') LOCAL_IP=$(hostname -I | awk '{print $1}')
sed -i -e "s|^APP_URL=|APP_URL=http://${LOCAL_IP}/bar/|" \ sed -i -e "s|^APP_URL=|APP_URL=http://${LOCAL_IP}/bar/|" \
-e "s|^MEILISEARCH_HOST=|MEILISEARCH_HOST=http://127.0.0.1:7700|" \ -e "s|^MEILISEARCH_HOST=|MEILISEARCH_HOST=http://127.0.0.1:7700|" \
-e "s|^MEILISEARCH_KEY=|MEILISEARCH_KEY=${MASTER_KEY}|" \ -e "s|^MEILISEARCH_KEY=|MEILISEARCH_KEY=${MASTER_KEY}|" \
-e "s|^MEILISEARCH_API_KEY=|MEILISEARCH_API_KEY=${MeiliSearch_API_KEY}|" \ -e "s|^MEILISEARCH_API_KEY=|MEILISEARCH_API_KEY=${MeiliSearch_API_KEY}|" \
-e "s|^MEILISEARCH_API_KEY_UID=|MEILISEARCH_API_KEY_UID=${MeiliSearch_API_KEY_UID}|" \ -e "s|^MEILISEARCH_API_KEY_UID=|MEILISEARCH_API_KEY_UID=${MeiliSearch_API_KEY_UID}|" \
/opt/bar-assistant/.env /opt/bar-assistant/.env
$STD composer install --no-interaction $STD composer install --no-interaction
$STD php artisan key:generate $STD php artisan key:generate
touch storage/bar-assistant/database.ba3.sqlite touch storage/bar-assistant/database.ba3.sqlite
@ -96,15 +91,9 @@ $STD php artisan route:cache
$STD php artisan event:cache $STD php artisan event:cache
mkdir /opt/bar-assistant/storage/bar-assistant/uploads/temp mkdir /opt/bar-assistant/storage/bar-assistant/uploads/temp
chown -R www-data:www-data /opt/bar-assistant chown -R www-data:www-data /opt/bar-assistant
echo "${RELEASE_BARASSISTANT}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Bar Assistant" msg_ok "Installed Bar Assistant"
msg_info "Installing Salt Rim" msg_info "Installing Salt Rim"
RELEASE_SALTRIM=$(curl -s https://api.github.com/repos/karlomikus/vue-salt-rim/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
cd /opt
curl -fsSL "https://github.com/karlomikus/vue-salt-rim/archive/refs/tags/v${RELEASE_SALTRIM}.zip" -o saltrim.zip
unzip -q saltrim.zip
mv /opt/vue-salt-rim-${RELEASE_SALTRIM}/ /opt/vue-salt-rim
cd /opt/vue-salt-rim cd /opt/vue-salt-rim
cat <<EOF >/opt/vue-salt-rim/public/config.js cat <<EOF >/opt/vue-salt-rim/public/config.js
window.srConfig = {} window.srConfig = {}
@ -113,7 +102,6 @@ window.srConfig.MEILISEARCH_URL = "http://${LOCAL_IP}/search"
EOF EOF
$STD npm install $STD npm install
$STD npm run build $STD npm run build
echo "${RELEASE_SALTRIM}" >/opt/vue-salt-rim_version.txt
msg_ok "Installed Salt Rim" msg_ok "Installed Salt Rim"
msg_info "Creating Service" msg_info "Creating Service"
@ -201,9 +189,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf /opt/meilisearch.deb
rm -rf "/opt/barassistant.zip"
rm -rf "/opt/saltrim.zip"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"