Skip to content

Commit 53807c9

Browse files
SnipeIT install Script (#538)
* Bare Metal install Script for SnipeIT * Fixed Copyright Header * Worked in all requested Changes and also added the Update function. Per my testing all is working as intendet.
1 parent 8301204 commit 53807c9

File tree

3 files changed

+232
-0
lines changed

3 files changed

+232
-0
lines changed

ct/snipeit.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
4+
#Copyright (c) 2021-2024 community-scripts ORG
5+
# Author: Michel Roegl-Brunner (michelroegl-brunner)
6+
# License: MIT
7+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
8+
function header_info {
9+
clear
10+
cat <<"EOF"
11+
_____ _ __________
12+
/ ___/____ (_)___ ___ / _/_ __/
13+
\__ \/ __ \/ / __ \/ _ \______ / / / /
14+
___/ / / / / / /_/ / __/_____// / / /
15+
/____/_/ /_/_/ .___/\___/ /___/ /_/
16+
/_/
17+
EOF
18+
}
19+
header_info
20+
echo -e "Loading..."
21+
APP="SnipeIT"
22+
23+
var_disk="4"
24+
var_cpu="2"
25+
var_ram="2048"
26+
var_os="debian"
27+
var_version="12"
28+
variables
29+
color
30+
catch_errors
31+
32+
function default_settings() {
33+
CT_TYPE="1"
34+
PW=""
35+
CT_ID=$NEXTID
36+
HN=$NSAPP
37+
DISK_SIZE="$var_disk"
38+
CORE_COUNT="$var_cpu"
39+
RAM_SIZE="$var_ram"
40+
BRG="vmbr0"
41+
NET="dhcp"
42+
GATE=""
43+
APT_CACHER=""
44+
APT_CACHER_IP=""
45+
DISABLEIP6="no"
46+
MTU=""
47+
SD=""
48+
NS=""
49+
MAC=""
50+
VLAN=""
51+
SSH="no"
52+
VERB="no"
53+
echo_default
54+
}
55+
56+
function update_script() {
57+
header_info
58+
check_container_storage
59+
check_container_resources
60+
if [[ ! -d /opt/snipe-it ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
61+
msg_info "Updating ${APP} LXC"
62+
apt-get update &>/dev/null
63+
apt-get -y upgrade &>/dev/null
64+
mv /opt/snipe-it /opt/snipe-it-backup
65+
cd /opt
66+
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
67+
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip" &>/dev/null
68+
unzip -q v${RELEASE}.zip
69+
mv snipe-it-${RELEASE} /opt/snipe-it
70+
cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
71+
cp -r /opt/snipe-it-backup/public/uploads/ /opt/snipe-it/public/uploads/
72+
cp -r /opt/snipe-it-backup/storage/private_uploads /opt/snipe-it/storage/private_uploads
73+
cd /opt/snipe-it/
74+
export COMPOSER_ALLOW_SUPERUSER=1
75+
composer install --no-dev --prefer-source &>/dev/null
76+
composer dump-autoload &>/dev/null
77+
php artisan migrate --force &>/dev/null
78+
php artisan config:clear &>/dev/null
79+
php artisan route:clear &>/dev/null
80+
php artisan cache:clear &>/dev/null
81+
php artisan view:clear &>/dev/null
82+
chown -R www-data: /opt/snipe-it
83+
chmod -R 755 /opt/snipe-it
84+
rm -rf /opt/v${RELEASE}.zip
85+
rm -rf /opt/snipe-it-backup
86+
msg_ok "Updated ${APP} LXC"
87+
exit
88+
}
89+
90+
start
91+
build_container
92+
description
93+
94+
msg_ok "Completed Successfully!\n"

install/snipeit-install.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env bash
2+
3+
4+
#Copyright (c) 2021-2024 community-scripts ORG
5+
# Author: Michel Roegl-Brunner (michelroegl-brunner)
6+
# License: MIT
7+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
8+
9+
10+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
11+
color
12+
verb_ip6
13+
catch_errors
14+
setting_up_container
15+
network_check
16+
update_os
17+
18+
msg_info "Installing Dependencies"
19+
$STD apt-get install -y \
20+
curl \
21+
composer \
22+
git \
23+
sudo \
24+
mc \
25+
nginx \
26+
php8.2-{bcmath,common,ctype,curl,fileinfo,fpm,gd,iconv,intl,mbstring,mysql,soap,xml,xsl,zip,cli} \
27+
mariadb-server
28+
msg_ok "Installed Dependencies"
29+
30+
msg_info "Setting up database"
31+
DB_NAME=snipeit_db
32+
DB_USER=snipeit
33+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
34+
mysql -u root -e "CREATE DATABASE $DB_NAME;"
35+
mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
36+
mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
37+
{
38+
echo "SnipeIT-Credentials"
39+
echo "SnipeIT Database User: $DB_USER"
40+
echo "SnipeIT Database Password: $DB_PASS"
41+
echo "SnipeIT Database Name: $DB_NAME"
42+
} >> ~/snipeit.creds
43+
msg_ok "Set up database"
44+
45+
msg_info "Installing Snipe-IT"
46+
cd /opt
47+
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
48+
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
49+
unzip -q v${RELEASE}.zip
50+
mv snipe-it-${RELEASE} /opt/snipe-it
51+
52+
cd /opt/snipe-it
53+
cp .env.example .env
54+
IPADDRESS=$(hostname -I | awk '{print $1}')
55+
56+
sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
57+
-e "s|^DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" \
58+
-e "s|^DB_USERNAME=.*|DB_USERNAME=$DB_USER|" \
59+
-e "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
60+
61+
chown -R www-data: /opt/snipe-it
62+
chmod -R 755 /opt/snipe-it
63+
64+
65+
export COMPOSER_ALLOW_SUPERUSER=1
66+
$STD composer update --no-plugins --no-scripts
67+
$STD composer install --no-dev --prefer-source --no-plugins --no-scripts
68+
69+
$STD php artisan key:generate --force
70+
msg_ok "Installed SnipeIT"
71+
72+
msg_info "Creating Service"
73+
74+
cat <<EOF >/etc/nginx/conf.d/snipeit.conf
75+
server {
76+
listen 80;
77+
root /opt/snipe-it/public;
78+
server_name $IPADDRESS;
79+
index index.php;
80+
81+
location / {
82+
try_files \$uri \$uri/ /index.php?\$query_string;
83+
}
84+
85+
location ~ \.php\$ {
86+
include fastcgi.conf;
87+
include snippets/fastcgi-php.conf;
88+
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
89+
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
90+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
91+
include fastcgi_params;
92+
}
93+
}
94+
EOF
95+
96+
systemctl reload nginx
97+
msg_ok "Configured Service"
98+
99+
100+
motd_ssh
101+
customize
102+
103+
msg_info "Cleaning up"
104+
rm -rf /opt/v${RELEASE}.zip
105+
$STD apt-get -y autoremove
106+
$STD apt-get -y autoclean
107+
msg_ok "Cleaned"

json/snipeit.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "SnipeIT",
3+
"slug": "snipeit",
4+
"categories": [
5+
8
6+
],
7+
"date_created": "2024-25-11",
8+
"type": "ct",
9+
"updateable": false,
10+
"privileged": false,
11+
"interface_port": null,
12+
"documentation": null,
13+
"website": "https://snipeitapp.com/",
14+
"logo": "https://github.com/snipe/snipe-it/blob/master/public/img/logo.png",
15+
"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.",
16+
"install_methods":{
17+
"type": "default",
18+
"script": "ct/snipeit.sh",
19+
"resources": {
20+
"cpu": "2",
21+
"ram": "2048",
22+
"hdd": "4",
23+
"os": "debian",
24+
"version": "12"
25+
}
26+
},
27+
"default_credentials": {
28+
"username": null,
29+
"password": null
30+
}
31+
}

0 commit comments

Comments
 (0)