mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-07 00:09:18 +00:00
Worked in all requested Changes and also added the Update function.
Per my testing all is working as intendet.
This commit is contained in:
parent
d1933ff5b8
commit
20a3084895
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||||
|
|
||||||
#Copyright (c) 2021-2024 community-scripts ORG
|
#Copyright (c) 2021-2024 community-scripts ORG
|
||||||
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
@ -7,20 +8,19 @@ source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/m
|
|||||||
function header_info {
|
function header_info {
|
||||||
clear
|
clear
|
||||||
cat <<"EOF"
|
cat <<"EOF"
|
||||||
_____ _ _____ _______
|
_____ _ __________
|
||||||
/ ____| (_) |_ _|__ __|
|
/ ___/____ (_)___ ___ / _/_ __/
|
||||||
| (___ _ __ _ _ __ ___ | | | |
|
\__ \/ __ \/ / __ \/ _ \______ / / / /
|
||||||
\___ \| '_ \| | '_ \ / _ \ | | | |
|
___/ / / / / / /_/ / __/_____// / / /
|
||||||
____) | | | | | |_) | __/_| |_ | |
|
/____/_/ /_/_/ .___/\___/ /___/ /_/
|
||||||
|_____/|_| |_|_| .__/ \___|_____| |_|
|
/_/
|
||||||
| |
|
|
||||||
|_|
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
header_info
|
header_info
|
||||||
echo -e "Loading..."
|
echo -e "Loading..."
|
||||||
APP="SnipeIT"
|
APP="SnipeIT"
|
||||||
var_disk="20"
|
|
||||||
|
var_disk="4"
|
||||||
var_cpu="2"
|
var_cpu="2"
|
||||||
var_ram="2048"
|
var_ram="2048"
|
||||||
var_os="debian"
|
var_os="debian"
|
||||||
@ -34,7 +34,7 @@ function default_settings() {
|
|||||||
PW=""
|
PW=""
|
||||||
CT_ID=$NEXTID
|
CT_ID=$NEXTID
|
||||||
HN=$NSAPP
|
HN=$NSAPP
|
||||||
DISK_SIZE="$var_disk"
|
DISK_SIZE="$var_disk"
|
||||||
CORE_COUNT="$var_cpu"
|
CORE_COUNT="$var_cpu"
|
||||||
RAM_SIZE="$var_ram"
|
RAM_SIZE="$var_ram"
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
@ -57,10 +57,32 @@ function update_script() {
|
|||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
if [[ ! -d /opt/snipe-it ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
||||||
msg_info "Updating ${APP} LXC"
|
msg_info "Updating ${APP} LXC"
|
||||||
apt-get update &>/dev/null
|
apt-get update &>/dev/null
|
||||||
apt-get -y upgrade &>/dev/null
|
apt-get -y upgrade &>/dev/null
|
||||||
|
mv /opt/snipe-it /opt/snipe-it-backup
|
||||||
|
cd /opt
|
||||||
|
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
|
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip" &>/dev/null
|
||||||
|
unzip -q v${RELEASE}.zip
|
||||||
|
mv snipe-it-${RELEASE} /opt/snipe-it
|
||||||
|
cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
|
||||||
|
cp -r /opt/snipe-it-backup/public/uploads/ /opt/snipe-it/public/uploads/
|
||||||
|
cp -r /opt/snipe-it-backup/storage/private_uploads /opt/snipe-it/storage/private_uploads
|
||||||
|
cd /opt/snipe-it/
|
||||||
|
export COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
composer install --no-dev --prefer-source &>/dev/null
|
||||||
|
composer dump-autoload &>/dev/null
|
||||||
|
php artisan migrate --force &>/dev/null
|
||||||
|
php artisan config:clear &>/dev/null
|
||||||
|
php artisan route:clear &>/dev/null
|
||||||
|
php artisan cache:clear &>/dev/null
|
||||||
|
php artisan view:clear &>/dev/null
|
||||||
|
chown -R www-data: /opt/snipe-it
|
||||||
|
chmod -R 755 /opt/snipe-it
|
||||||
|
rm -rf /opt/v${RELEASE}.zip
|
||||||
|
rm -rf /opt/snipe-it-backup
|
||||||
msg_ok "Updated ${APP} LXC"
|
msg_ok "Updated ${APP} LXC"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
#Copyright (c) 2021-2024 community-scripts ORG
|
#Copyright (c) 2021-2024 community-scripts ORG
|
||||||
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
# Author: Michel Roegl-Brunner (michelroegl-brunner)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
|
||||||
|
|
||||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
color
|
color
|
||||||
verb_ip6
|
verb_ip6
|
||||||
@ -13,89 +16,92 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt-get install -y curl
|
$STD apt-get install -y \
|
||||||
$STD apt-get install -y git
|
curl \
|
||||||
$STD apt-get install -y sudo
|
composer \
|
||||||
$STD apt-get install -y mc
|
git \
|
||||||
$STD apt-get install -y nginx
|
sudo \
|
||||||
$STD apt-get install -y php8.2-{bcmath,common,ctype,curl,fileinfo,fpm,gd,iconv,intl,mbstring,mysql,soap,xml,xsl,zip,cli}
|
mc \
|
||||||
$STD apt-get install -y mariadb-server
|
nginx \
|
||||||
|
php8.2-{bcmath,common,ctype,curl,fileinfo,fpm,gd,iconv,intl,mbstring,mysql,soap,xml,xsl,zip,cli} \
|
||||||
|
mariadb-server
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
msg_info "Installing Composer"
|
msg_info "Setting up database"
|
||||||
curl -sS https://getcomposer.org/installer -o composer-setup.php
|
DB_NAME=snipeit_db
|
||||||
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
DB_USER=snipeit
|
||||||
msg_ok "Installed Composer"
|
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||||
|
mysql -u root -e "CREATE DATABASE $DB_NAME;"
|
||||||
|
mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
|
||||||
|
mysql -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_ok "Configre Database\n"
|
msg_info "Installing Snipe-IT"
|
||||||
read -r -p "Enter password for Database user: " password
|
cd /opt
|
||||||
echo -e 'CREATE DATABASE snipeit;' | mysql
|
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
echo -e "GRANT ALL ON snipeit.* TO snipeit@localhost identified by '$password';" | mysql
|
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
|
||||||
echo -e 'FLUSH PRIVILEGES;' | mysql
|
unzip -q v${RELEASE}.zip
|
||||||
msg_ok "Configured Database"
|
mv snipe-it-${RELEASE} /opt/snipe-it
|
||||||
|
|
||||||
msg_info "Clone SnipeIT from Github"
|
cd /opt/snipe-it
|
||||||
cd /var/www/html
|
|
||||||
git clone https://github.com/snipe/snipe-it snipe-it
|
|
||||||
msg_ok "Finished cloning"
|
|
||||||
|
|
||||||
msg_info "Configure SnipeIT"
|
|
||||||
cd snipe-it
|
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
IPADDRESS=$(hostname -I | awk '{print $1}')
|
IPADDRESS=$(hostname -I | awk '{print $1}')
|
||||||
sed -i "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" .env
|
|
||||||
|
|
||||||
sed -i "s|^DB_DATABASE=.*|DB_DATABASE=snipeit|" .env
|
sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
|
||||||
sed -i "s|^DB_USERNAME=.*|DB_USERNAME=snipeit|" .env
|
-e "s|^DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" \
|
||||||
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$password|" .env
|
-e "s|^DB_USERNAME=.*|DB_USERNAME=$DB_USER|" \
|
||||||
chown -R www-data: /var/www/html/snipe-it
|
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
|
||||||
chmod -R 755 /var/www/html/snipe-it
|
|
||||||
git config --global --add safe.directory /var/www/html/snipe-it
|
chown -R www-data: /opt/snipe-it
|
||||||
|
chmod -R 755 /opt/snipe-it
|
||||||
|
|
||||||
msg_ok "Configred SnipeIT"
|
|
||||||
|
|
||||||
msg_info "Update SnipeIT dependencies"
|
|
||||||
export COMPOSER_ALLOW_SUPERUSER=1
|
export COMPOSER_ALLOW_SUPERUSER=1
|
||||||
composer update --no-plugins --no-scripts
|
$STD composer update --no-plugins --no-scripts
|
||||||
composer install --no-dev --prefer-source --no-plugins --no-scripts
|
$STD composer install --no-dev --prefer-source --no-plugins --no-scripts
|
||||||
msg_ok "Update OK"
|
|
||||||
|
|
||||||
msg_info "Generate APP_KEY"
|
$STD php artisan key:generate --force
|
||||||
php artisan key:generate --force
|
msg_ok "Installed SnipeIT"
|
||||||
msg_ok "Done"
|
|
||||||
|
|
||||||
msg_info "Configure NGINX"
|
msg_info "Creating Service"
|
||||||
echo -e '
|
|
||||||
|
cat <<EOF >/etc/nginx/conf.d/snipeit.conf
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name '$IPADDRESS';
|
root /opt/snipe-it/public;
|
||||||
root /var/www/html/snipe-it/public;
|
server_name $IPADDRESS;
|
||||||
|
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
try_files \$uri \$uri/ /index.php?\$query_string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php\$ {
|
||||||
include fastcgi.conf;
|
include fastcgi.conf;
|
||||||
include snippets/fastcgi-php.conf;
|
include snippets/fastcgi-php.conf;
|
||||||
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
|
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
}' > /etc/nginx/conf.d/snipeit.conf
|
}
|
||||||
systemctl restart nginx
|
EOF
|
||||||
msg_ok "Configured NGINX"
|
|
||||||
|
systemctl reload nginx
|
||||||
|
msg_ok "Configured Service"
|
||||||
|
|
||||||
msg_ok "SnipeIT is up and running, head to $IPADDRESS to reach the site"
|
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
|
rm -rf /opt/v${RELEASE}.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"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"privileged": false,
|
"privileged": false,
|
||||||
"interface_port": null,
|
"interface_port": null,
|
||||||
"documentation": null,
|
"documentation": null,
|
||||||
"website": "https://snipe-it.readme.io/docs/introduction",
|
"website": "https://snipeitapp.com/",
|
||||||
"logo": "https://github.com/snipe/snipe-it/blob/master/public/img/logo.png",
|
"logo": "https://github.com/snipe/snipe-it/blob/master/public/img/logo.png",
|
||||||
"description": "This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.",
|
"description": "This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.",
|
||||||
"install_methods":{
|
"install_methods":{
|
||||||
@ -19,7 +19,7 @@
|
|||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "2",
|
"cpu": "2",
|
||||||
"ram": "2048",
|
"ram": "2048",
|
||||||
"hdd": "20",
|
"hdd": "4",
|
||||||
"os": "debian",
|
"os": "debian",
|
||||||
"version": "12"
|
"version": "12"
|
||||||
}
|
}
|
||||||
@ -27,10 +27,5 @@
|
|||||||
"default_credentials": {
|
"default_credentials": {
|
||||||
"username": null,
|
"username": null,
|
||||||
"password": null
|
"password": null
|
||||||
},
|
}
|
||||||
"notes":
|
|
||||||
{
|
|
||||||
"text": "If the LXC is created Privileged, the script will automatically set up USB passthrough.",
|
|
||||||
"type": "warning"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user