Skip to content

Commit

Permalink
Merge pull request #3 from petrknap/molireali
Browse files Browse the repository at this point in the history
Refactored via molireali
  • Loading branch information
petrknap authored Nov 27, 2023
2 parents c243fa8 + 5ac208e commit b25ac6e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 12 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/linter-php.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PHP Linter

on:
pull_request:
paths:
- '**.php'

jobs:
PHP:
runs-on: ubuntu-latest
container:
image: php:7.3-cli-alpine
steps:
- uses: actions/checkout@v3
- run: find . -name '*.php' | xargs -trn 1 php -l
14 changes: 14 additions & 0 deletions .github/workflows/linter-shell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Shell Linter

on:
pull_request:
paths:
- '**.bash'
- '**.sh'

jobs:
ShellCheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: find . -name '*.bash' -or -name '*.sh' | xargs -tr shellcheck
3 changes: 3 additions & 0 deletions .molireali
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github-workflow linter-php 7.3
github-workflow linter-shell
license MIT 2023 "Petr Knap"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Petr Knap

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Petr Knap's home repository

This repository contains instructions on how to set up computers.

---

6 changes: 3 additions & 3 deletions bin/clean_backup → bin/clean_backup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ clean_backup() {
YEAR="${2:0:4}"
shift
FIND="find ${TARGET} -maxdepth 1 -name ${YEAR}-*_*"
for DATE in ${*}
for DATE in "${@}"
do
FIND="${FIND} -not -name ${DATE}_*"
done
if [[ `${FIND} | wc -l` -gt 0 ]]
if [[ $(${FIND} | wc -l) -gt 0 ]]
then
echo -e "\nPress [Enter] to clean backups based on this search:\n\t${FIND}" 1>&2
read
read -r
${FIND} -exec rm -rfv {} \;
fi
}
Expand Down
4 changes: 2 additions & 2 deletions bin/remote_backup → bin/remote_backup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bash -c " \
if [[ \"${BACKUP_ID}\" != \"\" ]]; then wget -O- \"https://backup.petrknap.cz/touch.php?id=${BACKUP_ID}\"; fi \
) \
|| ( \
rm "${LAST_WORKING_DIR}"; \
ln -s "${WORKING_DIR}" "${LAST_WORKING_DIR}"; \
rm \"${LAST_WORKING_DIR}\"; \
ln -s \"${WORKING_DIR}\" \"${LAST_WORKING_DIR}\"; \
) \
"
File renamed without changes.
10 changes: 5 additions & 5 deletions raspberry_pi_zero.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ tmpfs /var/log tmpfs defaults,noatime,nosuid,size=64m 0 0
1. `sudo nano /etc/fstab` and insert `/dev/mapper/backup /media/backup ext4 defaults,rw 0 0`


### Create `/home/pi/remote_backup`
### Create `/home/pi/remote_backup.bash`

```bash
#!/usr/bin/env bash
Expand Down Expand Up @@ -166,7 +166,7 @@ if [[ ! -e "/media/backup/local" ]]; then
mkdir "/media/backup/local"
fi

./bin/remote_backup "/home/pi" 22 "/media/backup/local" "
./bin/remote_backup.bash "/home/pi" 22 "/media/backup/local" "
.home
.cache
.config
Expand All @@ -181,7 +181,7 @@ if [[ ! -e "/media/backup/server" ]]; then
mkdir "/media/backup/server"
fi

./bin/remote_backup "{user}@{public IP}:/home/" {public port} "/media/backup/server" "
./bin/remote_backup.bash "{user}@{public IP}:/home/" {public port} "/media/backup/server" "
*.img
*/.keep
user/.cache
Expand All @@ -201,8 +201,8 @@ if [[ ! -e "/media/backup/ftp/hosting" ]]; then
mkdir -p "/media/backup/ftp/hosting"
fi

./bin/wget_mirror "ftp://{public IP}:{public port}/{folder}" "/media/backup/ftp" {user} {password}
./bin/remote_backup "/media/backup/ftp/hosting" 22 "/media/backup/hosting" "
./bin/wget_mirror.bash "ftp://{public IP}:{public port}/{folder}" "/media/backup/ftp" {user} {password}
./bin/remote_backup.bash "/media/backup/ftp/hosting" 22 "/media/backup/hosting" "
*/.listing
" "" "${BACKUP}"
); fi
Expand Down
4 changes: 2 additions & 2 deletions roles/Git/files/macros.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ git() {
command echo " You must specify branch as 3rd parameter."
else
MERGED_TO="$3"
for MERGED_BRANCH in `command git branch --merged "$MERGED_TO" | grep -v "$MERGED_TO" | grep -v "main" | grep -v "*"`
for MERGED_BRANCH in $(command git branch --merged "$MERGED_TO" | grep -v "$MERGED_TO" | grep -v "main" | grep -v "\*")
do
read -p "Are you sure you would like to delete $MERGED_BRANCH merged to $MERGED_TO? [Y/n] " CHOICE
read -rp "Are you sure you would like to delete $MERGED_BRANCH merged to $MERGED_TO? [Y/n] " CHOICE
if [[ "$CHOICE" == "Y" ]] || [[ "$CHOICE" == "y" ]] || [[ "$CHOICE" == "" ]]
then
command git branch --delete "$MERGED_BRANCH"
Expand Down

0 comments on commit b25ac6e

Please sign in to comment.