Skip to content

Commit 9c2f430

Browse files
Autoupdate
1 parent 8c80826 commit 9c2f430

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ One command installs a complete production stack. One command creates an isolate
1515
</p>
1616

1717
<p align="center">
18-
<img src="https://img.shields.io/badge/version-4.0.0-blue" alt="Version">
18+
<img src="https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fandreapollastri%2Fcipi%2Flatest%2Fversion.md&query=%24&label=version&color=blue" alt="Version">
1919
<img src="https://img.shields.io/badge/ubuntu-24.04+-orange" alt="Ubuntu">
2020
<img src="https://img.shields.io/badge/license-MIT-green" alt="License">
2121
<img src="https://img.shields.io/github/stars/andreapollastri/cipi?style=social" alt="Stars">
@@ -64,7 +64,7 @@ Installation takes about 10–15 minutes. At the end you'll see:
6464

6565
```
6666
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
67-
CIPI v4.0.0 INSTALLED SUCCESSFULLY
67+
CIPI vX.Y.Z INSTALLED SUCCESSFULLY
6868
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6969
7070
MariaDB Root
@@ -596,7 +596,7 @@ The update process:
596596
4. Runs **migration scripts** if the new version requires system changes (e.g., new Nginx config directives, new packages)
597597
5. Updates the version file
598598

599-
Migration scripts live in `lib/migrations/` and are named by version (e.g., `4.1.0.sh`). When updating from v4.0.0 to v4.2.0, Cipi automatically runs `4.1.0.sh` and `4.2.0.sh` in order. This means Cipi can evolve the server configuration over time without requiring a full reinstall.
599+
Migration scripts live in `lib/migrations/` and are named by version (e.g., `4.1.0.sh`). When updating, Cipi automatically runs any migration scripts newer than the installed version in order. This means Cipi can evolve the server configuration over time without requiring a full reinstall.
600600

601601
**Your apps, databases, and configurations are never touched by updates.** Only Cipi's own scripts are replaced.
602602

cipi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
#############################################
44
# Cipi - Server Control Panel for Laravel
5-
# Version: 4.0.0
5+
# Version: see /etc/cipi/version
66
# Author: Andrea Pollastri
77
# License: MIT
88
#############################################
99

1010
set -euo pipefail
1111

12-
readonly CIPI_VERSION="4.0.0"
1312
readonly CIPI_LIB="/opt/cipi/lib"
1413
readonly CIPI_CONFIG="/etc/cipi"
14+
readonly CIPI_VERSION="$(tr -d '[:space:]' < "${CIPI_CONFIG}/version" 2>/dev/null || echo "unknown")"
1515
readonly CIPI_LOG="/var/log/cipi"
1616

1717
RED=$'\033[0;31m'; GREEN=$'\033[0;32m'; YELLOW=$'\033[1;33m'

install.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
#############################################
44
# Cipi Installer
5-
# Version: 4.0.0
5+
# Version: see version.md
66
# Author: Andrea Pollastri
77
# License: MIT
88
#############################################
99

1010
set -e
1111

12-
BUILD="4.0.0"
1312
REPO="andreapollastri/cipi"
1413
BRANCH="${1:-latest}"
14+
BUILD="" # resolved from version.md after git clone in install_cipi()
1515

1616
RED='\033[0;31m'
1717
GREEN='\033[0;32m'
@@ -521,6 +521,9 @@ install_cipi() {
521521
rm -rf cipi-install
522522
git clone -b "$BRANCH" --depth 1 "https://github.com/${REPO}.git" cipi-install 2>/dev/null
523523

524+
BUILD="$(tr -d '[:space:]' < /tmp/cipi-install/version.md 2>/dev/null)"
525+
[[ -z "$BUILD" ]] && { echo "Cannot read version.md from repo"; exit 1; }
526+
524527
# Main CLI
525528
cp cipi-install/cipi /usr/local/bin/cipi
526529
chmod 700 /usr/local/bin/cipi
@@ -599,6 +602,8 @@ AUEOF
599602

600603
(crontab -l 2>/dev/null | grep -v "CIPI"; cat <<'CRONEOF'
601604
# === CIPI CRON JOBS ===
605+
# Cipi self-update (daily 3:50 AM)
606+
50 3 * * * /usr/local/bin/cipi self-update >> /var/log/cipi/cipi.log 2>&1
602607
# SSL renewal (Sunday 4 AM)
603608
10 4 * * 0 certbot renew --nginx --non-interactive --post-hook "systemctl reload nginx" >> /var/log/cipi/certbot.log 2>&1
604609
# Security updates — unattended-upgrades handles this daily via APT::Periodic

lib/self-update.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ selfupdate_command() {
99
parse_args "$@"
1010
local branch="${ARG_branch:-latest}"
1111
if [[ "${ARG_check:-}" == "true" ]]; then
12-
local rv; rv=$(curl -s "https://raw.githubusercontent.com/${_CIPI_REPO}/refs/heads/${branch}/cipi" 2>/dev/null|grep 'CIPI_VERSION='|head -1|cut -d'"' -f2)
12+
local rv; rv=$(curl -fsSL "https://raw.githubusercontent.com/${_CIPI_REPO}/refs/heads/${branch}/version.md" 2>/dev/null | tr -d '[:space:]')
1313
[[ -z "$rv" ]] && { error "Cannot check updates"; exit 1; }
1414
[[ "$rv" == "$CIPI_VERSION" ]] && success "Up to date (v${CIPI_VERSION})" || info "Update: v${CIPI_VERSION} → v${rv}"
1515
return
@@ -18,8 +18,8 @@ selfupdate_command() {
1818
step "Downloading from '${branch}'..."
1919
local tmp="/tmp/cipi-update-$$"; rm -rf "$tmp"
2020
git clone -b "$branch" --depth 1 "https://github.com/${_CIPI_REPO}.git" "$tmp" 2>/dev/null || { error "Download failed"; exit 1; }
21-
local nv; nv=$(grep 'CIPI_VERSION=' "${tmp}/cipi"|head -1|cut -d'"' -f2)
22-
[[ -z "$nv" ]] && { error "Invalid package"; rm -rf "$tmp"; exit 1; }
21+
local nv; nv=$(tr -d '[:space:]' < "${tmp}/version.md" 2>/dev/null)
22+
[[ -z "$nv" ]] && { error "Invalid package (version.md missing)"; rm -rf "$tmp"; exit 1; }
2323
info "Updating v${CIPI_VERSION} → v${nv}"
2424
cp -r /opt/cipi "/opt/cipi.bak.$(date +%Y%m%d%H%M%S)" 2>/dev/null||true
2525
cp "${tmp}/cipi" /usr/local/bin/cipi; chmod 700 /usr/local/bin/cipi

version.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.0

0 commit comments

Comments
 (0)