Skip to content
Snippets Groups Projects
Verified Commit 07e165f2 authored by David Beniamine's avatar David Beniamine
Browse files

Clean in a crontab

parent 8f5b3a1a
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
DIR=$(dirname $0)
cd /opt cd /opt
apt-get update apt-get update
...@@ -34,3 +36,7 @@ do ...@@ -34,3 +36,7 @@ do
systemctl enable $service systemctl enable $service
done done
# Add registry clean to cronab
line="0 1 1 * * $DIR/registry/scripts/clean.sh > /dev/null 2>&1"
(crontab -l; echo "${line}") | crontab -
#!/bin/bash
# Copyright (C) 2018 Tetras Libre <Contact@Tetras-Libre.fr>
# Author: Beniamine, David <David.Beniamine@Tetras-Libre.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
conf_dir="/etc/registry"
conf_file="$conf_dir/hosts"
while read line
do
if [ "$(echo $line | cut -d ' ' -f 1)" -gt "$(date -d '-6 month' +%Y%m%d)" ]
then
LINES="$LINES\n$(date +%Y%m%d) $(echo $line | cut -d ' ' -f 2-)"
fi
done < $conf_file
echo -e $LINES > $conf_file
...@@ -25,6 +25,7 @@ IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1) ...@@ -25,6 +25,7 @@ IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1)
port=9998 port=9998
conf_dir="/etc/registry" conf_dir="/etc/registry"
conf_file="$conf_dir/hosts" conf_file="$conf_dir/hosts"
DIR=$(dirname $0)
if [ ! -d $conf_dir ] if [ ! -d $conf_dir ]
then then
...@@ -33,14 +34,7 @@ then ...@@ -33,14 +34,7 @@ then
ssh-keygen -P "" -f /root/.ssh/id_rsa ssh-keygen -P "" -f /root/.ssh/id_rsa
else else
# Clean # Clean
while read line $DIR/clean.sh
do
if [ "$(echo $line | cut -d ' ' -f 1)" -gt "$(date -d '-6 month' +%Y%m%d)" ]
then
LINES="$LINES\n$(date +%Y%m%d) $(echo $line | cut -d ' ' -f 2-)"
fi
done < $conf_file
echo -e $LINES > $conf_file
fi fi
while true while true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment