Refactor (#7094)
This commit is contained in:
parent
c80f136871
commit
bae22ebf82
@ -20,38 +20,31 @@ color
|
|||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
function update_script() {
|
function update_script() {
|
||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
|
if [[ ! -d /opt/plant-it ]]; then
|
||||||
if [[ ! -d /opt/plant-it ]]; then
|
msg_error "No ${APP} Installation Found!"
|
||||||
msg_error "No ${APP} Installation Found!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/MDeLuise/plant-it/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
|
||||||
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
|
||||||
msg_info "Stopping $APP"
|
|
||||||
systemctl stop plant-it
|
|
||||||
msg_ok "Stopped $APP"
|
|
||||||
|
|
||||||
msg_info "Updating $APP to v${RELEASE}"
|
|
||||||
curl -fsSL "https://github.com/MDeLuise/plant-it/releases/download/${RELEASE}/server.jar" -o "/opt/plant-it/server.jar"
|
|
||||||
cd /opt/plant-it/frontend
|
|
||||||
curl -fsSL "https://github.com/MDeLuise/plant-it/releases/download/${RELEASE}/client.tar.gz" -o $(basename "https://github.com/MDeLuise/plant-it/releases/download/${RELEASE}/client.tar.gz")
|
|
||||||
tar -xzf client.tar.gz
|
|
||||||
rm -f client.tar.gz
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Updated $APP to v${RELEASE}"
|
|
||||||
|
|
||||||
msg_info "Starting $APP"
|
|
||||||
systemctl start plant-it
|
|
||||||
msg_ok "Started $APP"
|
|
||||||
msg_ok "Update Successful"
|
|
||||||
else
|
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
|
||||||
fi
|
|
||||||
exit
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
RELEASE=$(curl -fsSL https://api.github.com/repos/MDeLuise/plant-it/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
if [[ "${RELEASE}" != "$(cat ~/.plant-it 2>/dev/null)" ]] || [[ ! -f ~/.plant-it ]]; then
|
||||||
|
msg_info "Stopping $APP"
|
||||||
|
systemctl stop plant-it
|
||||||
|
msg_ok "Stopped $APP"
|
||||||
|
|
||||||
|
USE_ORIGINAL_FILENAME="true" fetch_and_deploy_gh_release "plant-it" "MDeLuise/plant-it" "singlefile" "latest" "/opt/plant-it/backend" "server.jar"
|
||||||
|
fetch_and_deploy_gh_release "plant-it-front" "MDeLuise/plant-it" "prebuild" "latest" "/opt/plant-it/frontend" "client.tar.gz"
|
||||||
|
|
||||||
|
msg_info "Starting $APP"
|
||||||
|
systemctl start plant-it
|
||||||
|
msg_ok "Started $APP"
|
||||||
|
msg_ok "Update Successful"
|
||||||
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||||
|
fi
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
start
|
start
|
||||||
|
@ -20,17 +20,7 @@ $STD apt-get install -y \
|
|||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
setup_mariadb
|
setup_mariadb
|
||||||
|
JAVA_VERSION="21" setup_java
|
||||||
msg_info "Setting up Adoptium Repository"
|
|
||||||
mkdir -p /etc/apt/keyrings
|
|
||||||
curl -fsSL "https://packages.adoptium.net/artifactory/api/gpg/key/public" | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg
|
|
||||||
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" >/etc/apt/sources.list.d/adoptium.list
|
|
||||||
$STD apt-get update
|
|
||||||
msg_ok "Set up Adoptium Repository"
|
|
||||||
|
|
||||||
msg_info "Installing Temurin JDK 21 (LTS)"
|
|
||||||
$STD apt-get install -y temurin-21-jdk
|
|
||||||
msg_ok "Setup Temurin JDK 21 (LTS)"
|
|
||||||
|
|
||||||
msg_info "Setting up MariaDB"
|
msg_info "Setting up MariaDB"
|
||||||
JWT_SECRET=$(openssl rand -base64 24 | tr -d '/+=')
|
JWT_SECRET=$(openssl rand -base64 24 | tr -d '/+=')
|
||||||
@ -48,13 +38,11 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS
|
|||||||
} >>~/plant-it.creds
|
} >>~/plant-it.creds
|
||||||
msg_ok "Set up MariaDB"
|
msg_ok "Set up MariaDB"
|
||||||
|
|
||||||
msg_info "Setup Plant-it"
|
USE_ORIGINAL_FILENAME="true" fetch_and_deploy_gh_release "plant-it" "MDeLuise/plant-it" "singlefile" "latest" "/opt/plant-it/backend" "server.jar"
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/MDeLuise/plant-it/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
fetch_and_deploy_gh_release "plant-it-front" "MDeLuise/plant-it" "prebuild" "latest" "/opt/plant-it/frontend" "client.tar.gz"
|
||||||
curl -fsSL "https://github.com/MDeLuise/plant-it/releases/download/${RELEASE}/server.jar" -o "server.jar"
|
|
||||||
mkdir -p /opt/plant-it/{backend,frontend}
|
|
||||||
mkdir -p /opt/plant-it-data
|
|
||||||
mv -f server.jar /opt/plant-it/backend/server.jar
|
|
||||||
|
|
||||||
|
msg_info "Configured Plant-it"
|
||||||
|
mkdir -p /opt/plant-it-data
|
||||||
cat <<EOF >/opt/plant-it/backend/server.env
|
cat <<EOF >/opt/plant-it/backend/server.env
|
||||||
MYSQL_HOST=localhost
|
MYSQL_HOST=localhost
|
||||||
MYSQL_PORT=3306
|
MYSQL_PORT=3306
|
||||||
@ -78,12 +66,7 @@ CACHE_TTL=86400
|
|||||||
CACHE_HOST=localhost
|
CACHE_HOST=localhost
|
||||||
CACHE_PORT=6379
|
CACHE_PORT=6379
|
||||||
EOF
|
EOF
|
||||||
|
msg_ok "Configured Plant-it"
|
||||||
cd /opt/plant-it/frontend
|
|
||||||
curl -fsSL "https://github.com/MDeLuise/plant-it/releases/download/${RELEASE}/client.tar.gz" -o "client.tar.gz"
|
|
||||||
tar -xzf client.tar.gz
|
|
||||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
|
||||||
msg_ok "Setup Plant-it"
|
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
cat <<EOF >/etc/systemd/system/plant-it.service
|
cat <<EOF >/etc/systemd/system/plant-it.service
|
||||||
@ -136,7 +119,6 @@ motd_ssh
|
|||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /opt/plant-it/frontend/client.tar.gz
|
|
||||||
$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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user