Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Shepherd Enterprise
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Subconscious Compute (Open)
Shepherd Enterprise
Commits
1f0260f7
Commit
1f0260f7
authored
11 months ago
by
Vipul
Browse files
Options
Downloads
Patches
Plain Diff
feat: cleanup implementation
parent
36f58c22
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setup-debian.sh
+37
-5
37 additions, 5 deletions
setup-debian.sh
with
37 additions
and
5 deletions
setup-debian.sh
+
37
−
5
View file @
1f0260f7
...
...
@@ -121,6 +121,7 @@ ensure_dependencies
# Variables
PROJECT_PATH
=
"/home/admin/shepherd-enterprise"
GIT_BRANCH
=
"patch-fix-storage-cleanup"
ENV_SHEPHERD_PATH
=
"
$PROJECT_PATH
/.env.shepherd"
ENV_CLIENT_PATH
=
"
$PROJECT_PATH
/.env.client"
...
...
@@ -135,6 +136,8 @@ CADDYFILE_PATH="$PROJECT_PATH/Caddyfile"
GRAFANADATA_PATH
=
"
$PROJECT_PATH
/grafanadata"
LOKIDATA_PATH
=
"
$PROJECT_PATH
/lokidata"
GIT_PATH
=
"
$PROJECT_PATH
/.git"
SCRIPT_PATH
=
"
$PROJECT_PATH
/setup-debian.sh"
SCRIPT_LOG_PATH
=
"
$PROJECT_PATH
/cron-logs/setup-debian-cron.log"
CRON_JOB
=
"0 0 * * *
$SCRIPT_PATH
>>
$SCRIPT_LOG_PATH
2>&1"
...
...
@@ -157,6 +160,35 @@ VIMACOG_HARD_GEN_EXISTS=$(crontab -l | grep -F "$VIMACOG_HARD_GEN_PATH" | grep -
VIMACOG_HARD_GEN_LOG_DIR
=
"
$PROJECT_PATH
/vimacog/hard-gen-logs/"
VIMACOG_HARD_GEN_BACKUP_DIR
=
"
$PROJECT_PATH
/vimacog/hard-gen-backup/"
# Note: Cleanup temporary storgae
cleanup_git
()
{
echo
"Initiating git cleanup..."
sudo du
-hc
$GIT_PATH
sudo
git fetch
-fpPv
origin
$GIT_BRANCH
echo
"Git cleanup complete."
sudo du
-hc
$GIT_PATH
}
cleanup_loki
()
{
echo
"Initiating loki logs cleanup..."
sudo du
-hc
$LOKIDATA_PATH
sudo rm
-rf
$LOKIDATA_PATH
/
*
echo
"Loki logs cleanup complete."
sudo du
-hc
$LOKIDATA_PATH
}
cleanup_docker
()
{
echo
"Initiating docker cleanup..."
sudo
docker system
df
sudo
docker system prune
-af
--volumes
echo
"Docker cleanup complete."
sudo
docker system
df
}
cleanup_git
cleanup_loki
cleanup_docker
# Check for Git updates & pull if updates are available
# Returns whether to hard run or soft run
# Note: Runs always
...
...
@@ -164,12 +196,12 @@ setup_git() {
echo
"Checking for git updates..."
cd
"
$PROJECT_PATH
"
||
exit
# git config pull.rebase true
sudo
git fetch origin
main
sudo
git fetch
-fpPv
origin
$GIT_BRANCH
if
[
"
$(
git rev-parse HEAD
)
"
!=
"
$(
git rev-parse FETCH_HEAD
)
"
]
;
then
# Ignore all local changes(comitted & non-comitted)
sudo
git reset
--hard
origin/
main
# TODO: Change this to
main
branch
sudo
git pull origin
main
--force
sudo
git reset
--hard
origin/
$GIT_BRANCH
# TODO: Change this to
$GIT_BRANCH
branch
sudo
git pull
-fpv
origin
$GIT_BRANCH
echo
"Repository updated. Applying updates..."
# Ensure the scripts are executable after a potential update
sudo chmod
+x
"
$SCRIPT_PATH
"
...
...
@@ -337,7 +369,7 @@ setup_docker() {
if
[
"
$force_update
"
=
true
]
;
then
echo
"Force updating images..."
sudo
docker compose down
sudo
docker system prune
-af
sudo
docker system prune
-af
--volumes
sudo
docker compose pull
sudo
docker compose
--env-file
./.env up
-d
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment