Ideas for CONTRIBUTING.md (#768)

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md
This commit is contained in:
Michel Roegl-Brunner 2024-12-10 14:34:00 +01:00 committed by GitHub
parent 483dc981f3
commit 4bde4d7d1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,6 +131,71 @@ function update_script() {
- `check_container_storage`: Checks available storage - `check_container_storage`: Checks available storage
- `check_container_resources`: Validates CPU/RAM resources - `check_container_resources`: Validates CPU/RAM resources
```bash
# Check if installation is present | -f for file, -d for folder
if [[ ! -f [INSTALLATION_CHECK_PATH] ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
```
> **Note**:
> - First you need to check if the APP is installed in the LXC
> - Replace ```INSTALLATION_CHECK_PATH``` with the path to the APP ```i.e. (/opt/app)```
```bash
# Crawling the new version and checking whether an update is required
RELEASE=$(curl -fsSL [RELEASE_URL] | [PARSE_RELEASE_COMMAND])
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
# Code to update the APP
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
```
> **Note**:
> - Crawl for the newest version. Example for Github Releases:
> - ```RELEASE=$(curl -s https://api.github.com/repos/USER/REPO/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')```
> - Then check if updating is required.
```bash
# Stopping Services
msg_info "Stopping $APP"
systemctl stop [SERVICE_NAME]
msg_ok "Stopped $APP"
# Creating Backup
msg_info "Creating Backup"
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" [IMPORTANT_PATHS]
msg_ok "Backup Created"
# Execute Update
msg_info "Updating $APP to v${RELEASE}"
[UPDATE_COMMANDS]
msg_ok "Updated $APP to v${RELEASE}"
# Starting Services
msg_info "Starting $APP"
systemctl start [SERVICE_NAME]
sleep 2
msg_ok "Started $APP"
# Cleaning up
msg_info "Cleaning Up"
rm -rf [TEMP_FILES]
msg_ok "Cleanup Completed"
# Last Action
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful"
```
> **Note**:
> - In the IF-Block you then write the code to update the APP, Start and Stop the Services and clean up any temporary files
## 6. 🏁 Script-End ## 6. 🏁 Script-End
```bash ```bash
@ -182,7 +247,10 @@ update_os
```bash ```bash
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y curl sudo mc $STD apt-get install -y \
curl \
sudo \
mc
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
``` ```
@ -231,8 +299,6 @@ $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"
``` ```
## 7. 📢 Progress Messages ## 7. 📢 Progress Messages
```bash ```bash
@ -250,12 +316,15 @@ echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
## 9. 🔐 Credentials Management ## 9. 🔐 Credentials Management
```bash ```bash
USERNAME=username
PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
{ {
echo "Application-Credentials" echo "Application-Credentials"
echo "Username: $USERNAME" echo "Username: $USERNAME"
echo "Password: $PASSWORD" echo "Password: $PASSWORD"
} >> ~/application.creds } >> ~/application.creds
``` ```
- Use random generated Passwords if possible
## 10. 📂 Directory Structure ## 10. 📂 Directory Structure
@ -308,7 +377,7 @@ git clone https://github.com/yourUserName/ForkName
### 3. Create a New Branch ### 3. Create a New Branch
```bash ```bash
git checkout -b your-feature-branch git switch -c your-feature-branch
``` ```
### 4. Change Paths in build.func and install.func ### 4. Change Paths in build.func and install.func