diff --git a/HelmCharts/miweb-chart/templates/miweb-deployment.yaml b/HelmCharts/miweb-chart/templates/miweb-deployment.yaml index 35548c08..ba99582c 100644 --- a/HelmCharts/miweb-chart/templates/miweb-deployment.yaml +++ b/HelmCharts/miweb-chart/templates/miweb-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: miweb + namespace: miweb spec: type: NodePort ports: @@ -16,6 +17,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: miweb + namespace: miweb labels: app: miweb spec: diff --git a/Nginx/pv-local-nginx.yaml b/HelmCharts/miweb-chart/templates/pv-local-nginx.yaml similarity index 83% rename from Nginx/pv-local-nginx.yaml rename to HelmCharts/miweb-chart/templates/pv-local-nginx.yaml index aafadf1e..128d1b3d 100644 --- a/Nginx/pv-local-nginx.yaml +++ b/HelmCharts/miweb-chart/templates/pv-local-nginx.yaml @@ -8,4 +8,4 @@ spec: accessModes: - ReadWriteMany hostPath: - path: "/mnt/cluster/nginx" + path: "/mnt/Externo/nginx" diff --git a/Nginx/pvc-nginx.yaml b/HelmCharts/miweb-chart/templates/pvc-nginx.yaml similarity index 81% rename from Nginx/pvc-nginx.yaml rename to HelmCharts/miweb-chart/templates/pvc-nginx.yaml index a8d80ec0..4e0b6823 100644 --- a/Nginx/pvc-nginx.yaml +++ b/HelmCharts/miweb-chart/templates/pvc-nginx.yaml @@ -1,7 +1,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: nginx-pv-claim + name: miweb-pv-claim + namespace: miweb labels: app: nginx spec: diff --git a/shells/borraAntiguos b/shells/borraAntiguos new file mode 100755 index 00000000..ec3fe2f3 --- /dev/null +++ b/shells/borraAntiguos @@ -0,0 +1,2 @@ +mysql -u crey -pRey-1176 estadopi -e "delete from estado where fecha < NOW() - INTERVAL 1 WEEK;" +mysql -u crey -pRey-1176 estadopi -e "delete from memoria where fecha < NOW() - INTERVAL 1 WEEK;" diff --git a/shells/copyDBK8S b/shells/copyDBK8S new file mode 100755 index 00000000..dfdc92d2 --- /dev/null +++ b/shells/copyDBK8S @@ -0,0 +1,23 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_fireflyiii +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n firefly|grep iii-mysql|cut -f1 -d' '` -n firefly -- /usr/bin/mysqldump -u root --password=Rey-1176 fireflyiii > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "FireflyIII backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/shells/copyDrupalDB b/shells/copyDrupalDB new file mode 100755 index 00000000..87ebb426 --- /dev/null +++ b/shells/copyDrupalDB @@ -0,0 +1,27 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_drupal +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +sudo kubectl --kubeconfig /home/creylopez/.kube/config -n drupal exec `sudo kubectl --kubeconfig /home/creylopez/.kube/config get pod -n drupal | grep mysql | cut -f1 -d' '` -- /usr/bin/mysqldump -u root --password=Dsa-0213 drupaldb > $new_name + +message="Backup stored "$today + +zip $new_name.zip $new_name + +sudo -u creylopez echo "Copia terminada" | mail -s "Drupal backup finished" "creylopez@yahoo.es" -A $new_name.zip + +sudo rm $new_name* + + diff --git a/shells/copyGogsDB b/shells/copyGogsDB new file mode 100755 index 00000000..58858fc5 --- /dev/null +++ b/shells/copyGogsDB @@ -0,0 +1,24 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_gogs +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +#sudo docker exec `sudo docker container ls | grep mysql_gogs | cut -f1 -d' '` /usr/bin/mysqldump -u root --password=Dsa-0213 gogs > $new_name +sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n gogs|grep mysql|cut -f1 -d' '` -n gogs -- /usr/bin/mysqldump -u root --password=Dsa-0213 gogs > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "Gogs backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/shells/copyKanboardDB b/shells/copyKanboardDB new file mode 100755 index 00000000..42c2cc6f --- /dev/null +++ b/shells/copyKanboardDB @@ -0,0 +1,23 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_kanboard +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n kanboard|grep mysql|cut -f1 -d' '` -n kanboard -- /usr/bin/mysqldump -u root --password=Dsa-0213 kanboard > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "Kanboard backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/shells/copyMediawikiDB b/shells/copyMediawikiDB new file mode 100755 index 00000000..eeac6347 --- /dev/null +++ b/shells/copyMediawikiDB @@ -0,0 +1,24 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_mediawiki +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +#sudo docker exec `sudo docker container ls | grep mysql_mediawiki | cut -f1 -d' '` /usr/bin/mysqldump -u root --password=Dsa-0213 mediawiki > $new_name +sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n mediawiki|grep mysql|cut -f1 -d' '` -n mediawiki -- /usr/bin/mysqldump -u root --password=Dsa-0213 mediawiki > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "Mediawiki backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/detectadMal b/shells/detectadMal similarity index 100% rename from detectadMal rename to shells/detectadMal diff --git a/shells/estadoPis b/shells/estadoPis new file mode 100755 index 00000000..f2f405a5 --- /dev/null +++ b/shells/estadoPis @@ -0,0 +1,56 @@ +# ssh crey@k8s-maestro "cat /sys/class/thermal/thermal_zone0/temp" +# Shell script: estado.sh +# Autor: Celestino Rey + +# Los remotos + +for i in k8s-maestro k8s-currante-01 k8s-currante-02 +do + cpu=$(ssh crey@$i "cat /sys/class/thermal/thermal_zone0/temp") + equipo=$i + tempcpu=$((cpu/1000)) + memtotal=$(ssh crey@$i "egrep 'MemTotal' /proc/meminfo |cut -c17-25") + memfree=$(ssh crey@$i "egrep 'MemFree' /proc/meminfo |cut -c17-25") + memavailable=$(ssh crey@$i "egrep 'MemAvailable' /proc/meminfo |cut -c17-25") + echo "------------------------------" + echo "Temp.CPU => $tempcpu'C" + echo "Equipo => $equipo" + echo "Memoria Total => $memtotal" + echo "Memoria libre => $memfree" + echo "Memoria disponible => $memavailable" + echo "------------------------------" + mysql -u crey -pRey-1176 estadopi -e "insert into estado (tempcpu,fecha,equipo) values($tempcpu,NOW(),'$equipo');" + mysql -u crey -pRey-1176 estadopi -e "insert into memoria (memtotal,memfree,memav,fecha,equipo) values($memtotal,$memfree,$memavailable,NOW(),'$equipo');" +done + +# El local + +cpu=$(cat /sys/class/thermal/thermal_zone0/temp) +equipo=$(hostname) +tempcpu=$((cpu/1000)) +memtotal=$(egrep 'MemTotal' /proc/meminfo |cut -c17-25) +memfree=$(egrep 'MemFree' /proc/meminfo |cut -c17-25) +memavalilable=$(egrep 'MemAvalilable' /proc/meminfo |cut -c17-25) +echo "------------------------------" +echo "Temp.CPU => $tempcpu'C" +echo "Equipo => $equipo" +echo "Memoria Total => $memtotal" +echo "Memoria libre => $memfree" +echo "Memoria disponible => $memavailable" +echo "------------------------------" +mysql -u crey -pRey-1176 estadopi -e "insert into estado (tempcpu,fecha,equipo) values($tempcpu,NOW(),'$equipo');" +mysql -u crey -pRey-1176 estadopi -e "insert into memoria (memtotal,memfree,memav,fecha,equipo) values($memtotal,$memfree,$memavailable,NOW(),'$equipo');" + +# el disco externo + +espaciototal=$(df |grep discoexterno |cut -c19-28) +espaciousado=$(df |grep discoexterno |cut -c29-36) +espaciolibre=$(df |grep discoexterno |cut -c39-48) + +libre=$(($espaciolibre/1000000)) +echo "------------------------------" +echo "Espacio total => $espaciototal" +echo "Espacio usado => $espaciousado" +echo "Espacio libre => $espaciolibre/$libre Gb" +echo "------------------------------" +mysql -u crey -pRey-1176 estadopi -e "insert into discoexterno (espaciototal,espaciousado,espaciolibre,fecha) values($espaciototal,$espaciousado,$libre,NOW());" diff --git a/shells/guardarestic.sh b/shells/guardarestic.sh new file mode 100755 index 00000000..645db0ac --- /dev/null +++ b/shells/guardarestic.sh @@ -0,0 +1 @@ +sudo restic -r /mnt/Family/restic-repo backup /mnt/cluster/ -p /home/creylopez/.restic diff --git a/shells/mientra.sh b/shells/mientra.sh new file mode 100755 index 00000000..9fcf0d1a --- /dev/null +++ b/shells/mientra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/nginx-php-dev -- /bin/bash diff --git a/shells/miraRestic.sh b/shells/miraRestic.sh new file mode 100755 index 00000000..2e0138e9 --- /dev/null +++ b/shells/miraRestic.sh @@ -0,0 +1 @@ +sudo restic -r /mnt/Family/restic-repo snapshots -p /home/creylopez/.restic diff --git a/shells/muestraPuertos.sh b/shells/muestraPuertos.sh new file mode 100644 index 00000000..8f983e46 --- /dev/null +++ b/shells/muestraPuertos.sh @@ -0,0 +1,5 @@ +kubectl get svc --all-namespaces |grep NodePort +while read -r line +do + echo "$line" | cut -c1-15 +done diff --git a/shells/noip2 b/shells/noip2 new file mode 100755 index 00000000..46cbb7d0 Binary files /dev/null and b/shells/noip2 differ diff --git a/NextCloud/syncNC2LaCie b/shells/syncNC2LaCie similarity index 74% rename from NextCloud/syncNC2LaCie rename to shells/syncNC2LaCie index 72aa95cb..f4f7742f 100755 --- a/NextCloud/syncNC2LaCie +++ b/shells/syncNC2LaCie @@ -2,7 +2,7 @@ comienzo=$(date "+%Y_%m_%d-%H_%M_%S") SINCRONIZANDO=/tmp/sincronizando LOG=/tmp/resultadosync.log -ORIGEN=/mnt/cluster +ORIGEN=/mnt/Externo DESTINO=/mnt/LaCie/BeeLink DESTINOext=/mnt/Externo/Cluster @@ -13,11 +13,11 @@ if [ ! -f "$SINCRONIZANDO" ] then touch $SINCRONIZANDO echo "Empieza sincronización..." >> $LOG - for i in fireflyiii nextcloud nginx reevolution wordpress + for i in fireflyiii nextcloud nginx mattermost hammond gogs navidrome mediawiki mealie kanboard wordpress registry vaultwarden do echo "Guardando '$i'..." >> $LOG -# sudo rsync -avh $ORIGEN/$i $DESTINO --delete >> $LOG - sudo rsync -avh $ORIGEN/$i $DESTINOext --delete >> $LOG + sudo rsync -avh $ORIGEN/$i $DESTINO --delete >> $LOG + #sudo rsync -avh $ORIGEN/$i $DESTINOext --delete >> $LOG done final=$(date "+%Y_%m_%d-%H_%M_%S") echo "$final - Fin de sincronizacion con LaCie" >> $LOG