Compare commits

...

10 Commits

Author SHA1 Message Date
bvdberg01
7f6086b182
Merge 5549524308 into fad540cf4c 2024-12-16 23:07:58 +00:00
community-scripts-pr-app[bot]
fad540cf4c
Update CHANGELOG.md (#859)
Some checks are pending
Create Changelog Pull Request / update-changelog-pull-request (push) Waiting to run
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-16 23:47:50 +01:00
Håvard Gjøby Thom
9256880c9f
Fix SSH root access in install.func (#858) 2024-12-16 23:43:32 +01:00
community-scripts-pr-app[bot]
5b38448107
Update CHANGELOG.md (#856)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-16 22:43:48 +01:00
Rémi Bédard-Couture
db1950a2bb
Fix variable name for CT_TYPE override (#855) 2024-12-16 22:41:01 +01:00
bvdberg01
5549524308
Migrate header & footer to latest version 2024-12-16 21:12:27 +01:00
community-scripts-pr-app[bot]
f449ca707a
Update CHANGELOG.md (#852)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-16 18:23:38 +01:00
Rémi Bédard-Couture
e410bdbf5e
Keeps the same style after writing the SEARCH icon (#851) 2024-12-16 18:21:41 +01:00
bvdberg01
326b63f1b0 Improved based on PR feedback MickLesk 2024-12-04 00:18:24 +01:00
bvdberg01
e36b13f15b New script: Part-DB LXC 2024-11-29 22:25:06 +01:00
6 changed files with 271 additions and 3 deletions

View File

@ -31,13 +31,19 @@ Do not break established syntax in this file, as it is automatically updated by
### 🚀 Updated Scripts
- Update Script: Remove Docker Compose Question [@michelroegl-brunner](https://github.com/michelroegl-brunner) ([#847](https://github.com/community-scripts/ProxmoxVE/pull/847))
- Increase Size | Description & Download-URL of Debian VM [@MickLesk](https://github.com/MickLesk) ([#837](https://github.com/community-scripts/ProxmoxVE/pull/837))
- Update Script: Remove Docker Compose Question [@michelroegl-brunner](https://github.com/michelroegl-brunner) ([#847](https://github.com/community-scripts/ProxmoxVE/pull/847))
### 🌐 Website
- Bump nanoid from 3.3.7 to 3.3.8 in /frontend [@dependabot[bot]](https://github.com/dependabot[bot]) ([#845](https://github.com/community-scripts/ProxmoxVE/pull/845))
### ❔ Unlabelled
- Fix SSH root access in install.func [@havardthom](https://github.com/havardthom) ([#858](https://github.com/community-scripts/ProxmoxVE/pull/858))
- Fix variable name for CT_TYPE override [@remz1337](https://github.com/remz1337) ([#855](https://github.com/community-scripts/ProxmoxVE/pull/855))
- Keeps the same style after writing the SEARCH icon [@remz1337](https://github.com/remz1337) ([#851](https://github.com/community-scripts/ProxmoxVE/pull/851))
## 2024-12-13
### Changed

106
ct/part-db.sh Normal file
View File

@ -0,0 +1,106 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2024 community-scripts ORG
# Author: bvdberg01
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://docs.part-db.de/
# App Default Values
APP="Part-DB"
var_tags="inventory;parts"
var_cpu="2"
var_ram="1024"
var_disk="8"
var_os="debian"
var_version="12"
var_unprivileged="1"
# App Output & Base Settings
header_info "$APP"
base_settings
# Core
variables
color
catch_errors
function default_settings() {
CT_TYPE="1"
PW=""
CT_ID=$NEXTID
HN=$NSAPP
DISK_SIZE="$var_disk"
CORE_COUNT="$var_cpu"
RAM_SIZE="$var_ram"
BRG="vmbr0"
NET="dhcp"
GATE=""
APT_CACHER=""
APT_CACHER_IP=""
DISABLEIP6="no"
MTU=""
SD=""
NS=""
MAC=""
VLAN=""
SSH="no"
VERB="no"
echo_default
}
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/partdb ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
RELEASE=$(curl -s https://api.github.com/repos/Part-DB/Part-DB-server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping Service"
systemctl stop apache2
msg_ok "Stopped Service"
msg_info "Updating $APP to v${RELEASE}"
cd /opt
mv /opt/partdb/ /opt/partdb-backup
wget -q "https://github.com/Part-DB/Part-DB-server/archive/refs/tags/v${RELEASE}.zip"
unzip -q "v${RELEASE}.zip"
mv /opt/Part-DB-server-${RELEASE}/ /opt/partdb
cd /opt/partdb/
cp -r "/opt/partdb-backup/.env.local" /opt/partdb/
cp -r "/opt/partdb-backup/public/media" /opt/partdb/public/
cp -r "/opt/partdb-backup/config/banner.md" /opt/partdb/config/
export COMPOSER_ALLOW_SUPERUSER=1
composer install --no-dev -o --no-interaction &>/dev/null
yarn install &>/dev/null
yarn build &>/dev/null
php bin/console cache:clear &>/dev/null
php bin/console doctrine:migrations:migrate -n &>/dev/null
chown -R www-data:www-data /opt/partdb
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service"
systemctl start apache2
msg_ok "Started Service"
msg_info "Cleaning up"
rm -r "/opt/v${RELEASE}.zip"
rm -r /opt/partdb-backup
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

112
install/part-db-install.sh Normal file
View File

@ -0,0 +1,112 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2024 community-scripts ORG
# Author: bvdberg01
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
curl \
sudo \
mc \
zip \
ca-certificates \
software-properties-common \
apt-transport-https \
lsb-release \
php-{opcache,curl,gd,mbstring,xml,bcmath,intl,zip,xsl,pgsql} \
libapache2-mod-php \
composer \
postgresql
msg_ok "Installed Dependencies"
msg_info "Setting up PostgreSQL"
DB_NAME=partdb
DB_USER=partdb
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;"
{
echo "Part-DB Credentials"
echo "Part-DB Database User: $DB_USER"
echo "Part-DB Database Password: $DB_PASS"
echo "Part-DB Database Name: $DB_NAME"
} >> ~/partdb.creds
msg_ok "Set up PostgreSQL"
msg_info "Setting up Node.js/Yarn"
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
$STD apt-get update
$STD apt-get install -y nodejs
$STD npm install -g npm@latest
$STD npm install -g yarn
msg_ok "Installed Node.js/Yarn"
msg_info "Installing Part-DB (Patience)"
cd /opt
RELEASE=$(curl -s https://api.github.com/repos/Part-DB/Part-DB-server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/Part-DB/Part-DB-server/archive/refs/tags/v${RELEASE}.zip"
unzip -q "v${RELEASE}.zip"
mv /opt/Part-DB-server-${RELEASE}/ /opt/partdb
cd /opt/partdb/
cp .env .env.local
sed -i "s|DATABASE_URL=\"sqlite:///%kernel.project_dir%/var/app.db\"|DATABASE_URL=\"postgresql://${DB_USER}:${DB_PASS}@127.0.0.1:5432/${DB_NAME}?serverVersion=12.19&charset=utf8\"|" .env.local
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-dev -o --no-interaction
$STD yarn install
$STD yarn build
$STD php bin/console cache:clear
php bin/console doctrine:migrations:migrate -n > ~/database-migration-output
chown -R www-data:www-data /opt/partdb
ADMIN_PASS=$(grep -oP 'The initial password for the "admin" user is: \K\w+' ~/database-migration-output)
{
echo ""
echo "Part-DB Admin User: admin"
echo "Part-DB Admin Password: $ADMIN_PASS"
} >> ~/partdb.creds
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Part-DB"
msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/partdb.conf
<VirtualHost *:80>
ServerName partdb
DocumentRoot /opt/partdb/public
<Directory /opt/partdb/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/partdb_error.log
CustomLog /var/log/apache2/partdb_access.log combined
</VirtualHost>
EOF
$STD a2ensite partdb
$STD a2enmod rewrite
$STD a2dissite 000-default.conf
$STD systemctl reload apache2
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
rm -rf ~/database-migration-output
rm -rf "/opt/v${RELEASE}.zip"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"

39
json/part-db.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "Part-DB",
"slug": "part-db",
"categories": [
0
],
"date_created": "2024-11-29",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": "80",
"documentation": "https://docs.part-db.de/",
"website": "https://github.com/Part-DB/Part-DB-server",
"logo": "https://avatars.githubusercontent.com/u/36010898?s=48&v=4",
"description": "Part-DB is an Open source inventory management system for your electronic components",
"install_methods": [
{
"type": "default",
"script": "ct/part-db.sh",
"resources": {
"cpu": "2",
"ram": "1024",
"hdd": "8",
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "Show login and database credentials: `cat part-db.creds`",
"type": "info"
}
]
}

View File

@ -204,7 +204,7 @@ base_settings() {
TAGS="community-script;"
# Override default settings with variables from ct script
CT_TYPE=${var_privileged:-$CT_TYPE}
CT_TYPE=${var_unprivileged:-$CT_TYPE}
DISK_SIZE=${var_disk:-$DISK_SIZE}
CORE_COUNT=${var_cpu:-$CORE_COUNT}
RAM_SIZE=${var_ram:-$RAM_SIZE}
@ -611,7 +611,7 @@ install_script() {
;;
2)
header_info
echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings (${SEARCH} Verbose)${CL}"
echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings (${SEARCH}${BOLD}${BL} Verbose)${CL}"
VERB="yes"
base_settings "$VERB"
echo_default

View File

@ -231,6 +231,11 @@ motd_ssh() {
# Disable default MOTD scripts
chmod -x /etc/update-motd.d/*
if [[ "${SSH_ROOT}" == "yes" ]]; then
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
systemctl restart sshd
fi
}
# This function customizes the container by modifying the getty service and enabling auto-login for the root user