mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-04-22 12:38:06 +00:00
Rework SnipeIT: Tarball & Tempfile (#2963)
* SnipeIT: Change Release to tarball * Update snipeit.sh * Update snipeit-install.sh * Update snipeit.sh
This commit is contained in:
parent
60994b6851
commit
1de7e428cd
@ -6,7 +6,7 @@ source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/m
|
|||||||
# Source: https://snipeitapp.com/
|
# Source: https://snipeitapp.com/
|
||||||
|
|
||||||
APP="SnipeIT"
|
APP="SnipeIT"
|
||||||
var_tags="assat-management;foss"
|
var_tags="asset-management;foss"
|
||||||
var_cpu="2"
|
var_cpu="2"
|
||||||
var_ram="2048"
|
var_ram="2048"
|
||||||
var_disk="4"
|
var_disk="4"
|
||||||
@ -27,13 +27,20 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "v([^"]+).*/\1/')
|
||||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
|
msg_info "Stopping Services"
|
||||||
|
systemctl stop nginx
|
||||||
|
msg_ok "Services Stopped"
|
||||||
|
|
||||||
msg_info "Updating ${APP} to v${RELEASE}"
|
msg_info "Updating ${APP} to v${RELEASE}"
|
||||||
$STD apt-get update
|
$STD apt-get update
|
||||||
$STD apt-get -y upgrade
|
$STD apt-get -y upgrade
|
||||||
mv /opt/snipe-it /opt/snipe-it-backup
|
mv /opt/snipe-it /opt/snipe-it-backup
|
||||||
cd /opt
|
temp_file=$(mktemp)
|
||||||
|
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
|
||||||
|
tar zxf $temp_file
|
||||||
|
mv snipe-it-${RELEASE} /opt/snipe-it
|
||||||
$STD wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
|
$STD wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
|
||||||
unzip -q v${RELEASE}.zip
|
unzip -q v${RELEASE}.zip
|
||||||
mv snipe-it-${RELEASE} /opt/snipe-it
|
mv snipe-it-${RELEASE} /opt/snipe-it
|
||||||
@ -53,9 +60,13 @@ function update_script() {
|
|||||||
chmod -R 755 /opt/snipe-it
|
chmod -R 755 /opt/snipe-it
|
||||||
rm -rf /opt/v${RELEASE}.zip
|
rm -rf /opt/v${RELEASE}.zip
|
||||||
rm -rf /opt/snipe-it-backup
|
rm -rf /opt/snipe-it-backup
|
||||||
msg_ok "Updated ${APP} LXC"
|
msg_ok "Updated ${APP}"
|
||||||
|
|
||||||
|
msg_info "Starting Service"
|
||||||
|
systemctl start nginx
|
||||||
|
msg_ok "Started Service"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,11 @@ mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVI
|
|||||||
msg_ok "Set up database"
|
msg_ok "Set up database"
|
||||||
|
|
||||||
msg_info "Installing Snipe-IT"
|
msg_info "Installing Snipe-IT"
|
||||||
cd /opt
|
temp_file=$(mktemp)
|
||||||
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "v([^"]+).*/\1/')
|
||||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
|
||||||
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
|
tar zxf $temp_file
|
||||||
unzip -q v${RELEASE}.zip
|
|
||||||
mv snipe-it-${RELEASE} /opt/snipe-it
|
mv snipe-it-${RELEASE} /opt/snipe-it
|
||||||
|
|
||||||
cd /opt/snipe-it
|
cd /opt/snipe-it
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
IPADDRESS=$(hostname -I | awk '{print $1}')
|
IPADDRESS=$(hostname -I | awk '{print $1}')
|
||||||
@ -59,17 +57,14 @@ sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
|
|||||||
|
|
||||||
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 update --no-plugins --no-scripts
|
$STD composer update --no-plugins --no-scripts
|
||||||
$STD composer install --no-dev --prefer-source --no-plugins --no-scripts
|
$STD composer install --no-dev --prefer-source --no-plugins --no-scripts
|
||||||
|
|
||||||
$STD php artisan key:generate --force
|
$STD php artisan key:generate --force
|
||||||
|
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||||
msg_ok "Installed SnipeIT"
|
msg_ok "Installed SnipeIT"
|
||||||
|
|
||||||
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;
|
||||||
@ -100,7 +95,7 @@ motd_ssh
|
|||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf /opt/v${RELEASE}.zip
|
rm -f $temp_file
|
||||||
$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