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
msg_ok "Services Stopped"
msg_info "Creating backup"
msg_info "Creating 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"
[[ "$(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
setup_composer
msg_info "Updating ${APP}"
msg_info "Updating Snipe-IT"
$STD apt update
$STD apt -y upgrade
cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
@ -63,7 +63,7 @@ function update_script() {
chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it
rm -rf /opt/snipe-it-backup
msg_ok "Updated ${APP}"
msg_ok "Updated Snipe-IT"
msg_info "Starting Service"
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
fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball"
setup_mariadb
msg_info "Setting up database"
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"
MARIADB_DB_NAME="snipeit_db" MARIADB_DB_USER="snipeit" setup_mariadb_db
import_local_ip
msg_info "Configuring Snipe-IT"
cd /opt/snipe-it
cp .env.example .env
IPADDRESS=$(hostname -I | awk '{print $1}')
sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
-e "s|^DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" \
-e "s|^DB_USERNAME=.*|DB_USERNAME=$DB_USER|" \
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
sed -i -e "s|^APP_URL=.*|APP_URL=http://$LOCAL_IP|" \
-e "s|^DB_DATABASE=.*|DB_DATABASE=$MARIADB_DB_NAME|" \
-e "s|^DB_USERNAME=.*|DB_USERNAME=$MARIADB_DB_USER|" \
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=$MARIADB_DB_PASS|" .env
chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-dev --optimize-autoloader --no-interaction
$STD php artisan key:generate --force
msg_ok "Configured SnipeIT"
msg_ok "Configured Snipe-IT"
msg_info "Creating Service"
cat <<EOF >/etc/nginx/conf.d/snipeit.conf
server {
listen 80;
root /opt/snipe-it/public;
server_name $IPADDRESS;
server_name $LOCAL_IP;
client_max_body_size 100M;
index index.php;