This commit is contained in:
Slaviša Arežina
2025-12-11 12:08:16 +01:00
committed by GitHub
parent 723f9d63d6
commit 1afefd20e9
2 changed files with 12 additions and 28 deletions

View File

@ -36,16 +36,16 @@ function update_script() {
systemctl stop nginx systemctl stop nginx
msg_ok "Services Stopped" msg_ok "Services Stopped"
msg_info "Creating backup" msg_info "Creating Backup"
mv /opt/snipe-it /opt/snipe-it-backup mv /opt/snipe-it /opt/snipe-it-backup
msg_ok "Backup created" msg_ok "Created Backup"
fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball" fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball"
[[ "$(php -v 2>/dev/null)" == PHP\ 8.2* ]] && PHP_VERSION="8.3" PHP_MODULE="common,ctype,ldap,fileinfo,iconv,mysql,soap,xsl" PHP_FPM="YES" setup_php [[ "$(php -v 2>/dev/null)" == PHP\ 8.2* ]] && PHP_VERSION="8.3" PHP_MODULE="common,ctype,ldap,fileinfo,iconv,mysql,soap,xsl" PHP_FPM="YES" setup_php
sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/snipeit.conf sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/snipeit.conf
setup_composer setup_composer
msg_info "Updating ${APP}" msg_info "Updating Snipe-IT"
$STD apt update $STD apt update
$STD apt -y upgrade $STD apt -y upgrade
cp /opt/snipe-it-backup/.env /opt/snipe-it/.env cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
@ -63,7 +63,7 @@ function update_script() {
chown -R www-data: /opt/snipe-it chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it chmod -R 755 /opt/snipe-it
rm -rf /opt/snipe-it-backup rm -rf /opt/snipe-it-backup
msg_ok "Updated ${APP}" msg_ok "Updated Snipe-IT"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start nginx systemctl start nginx

View File

@ -23,45 +23,29 @@ PHP_VERSION="8.3" PHP_MODULE="common,ctype,ldap,fileinfo,iconv,mysql,soap,xsl" P
setup_composer setup_composer
fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball" fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball"
setup_mariadb setup_mariadb
MARIADB_DB_NAME="snipeit_db" MARIADB_DB_USER="snipeit" setup_mariadb_db
msg_info "Setting up database" import_local_ip
DB_NAME=snipeit_db
DB_USER=snipeit
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{
echo "SnipeIT-Credentials"
echo "SnipeIT Database User: $DB_USER"
echo "SnipeIT Database Password: $DB_PASS"
echo "SnipeIT Database Name: $DB_NAME"
} >>~/snipeit.creds
msg_ok "Set up database"
msg_info "Configuring Snipe-IT" msg_info "Configuring Snipe-IT"
cd /opt/snipe-it cd /opt/snipe-it
cp .env.example .env cp .env.example .env
IPADDRESS=$(hostname -I | awk '{print $1}') sed -i -e "s|^APP_URL=.*|APP_URL=http://$LOCAL_IP|" \
-e "s|^DB_DATABASE=.*|DB_DATABASE=$MARIADB_DB_NAME|" \
sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \ -e "s|^DB_USERNAME=.*|DB_USERNAME=$MARIADB_DB_USER|" \
-e "s|^DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" \ -e "s|^DB_PASSWORD=.*|DB_PASSWORD=$MARIADB_DB_PASS|" .env
-e "s|^DB_USERNAME=.*|DB_USERNAME=$DB_USER|" \
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
chown -R www-data: /opt/snipe-it chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it chmod -R 755 /opt/snipe-it
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-dev --optimize-autoloader --no-interaction $STD composer install --no-dev --optimize-autoloader --no-interaction
$STD php artisan key:generate --force $STD php artisan key:generate --force
msg_ok "Configured SnipeIT" msg_ok "Configured Snipe-IT"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/nginx/conf.d/snipeit.conf cat <<EOF >/etc/nginx/conf.d/snipeit.conf
server { server {
listen 80; listen 80;
root /opt/snipe-it/public; root /opt/snipe-it/public;
server_name $IPADDRESS; server_name $LOCAL_IP;
client_max_body_size 100M; client_max_body_size 100M;
index index.php; index index.php;