Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clewsy
scripts
Commits
9391f993
Commit
9391f993
authored
Aug 14, 2020
by
clewsy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added checks an crosses.
parent
ed38c252
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
apt_all.sh
apt_all.sh
+14
-14
No files found.
apt_all.sh
View file @
9391f993
...
...
@@ -25,8 +25,8 @@ TIMESTAMP () { echo -ne "$(date +%Y-%m-%d\ %T)"; }
########## Function for exit conditions. Log error or success and exit.
QUIT
()
{
if
[
"
${
1
}
"
-gt
0
]
;
then
echo
-e
"
$(
TIMESTAMP
)
-
Script failed with error code
${
1
}
."
>>
"
${
APT_ALL_LOG_FILE
}
"
else
echo
-e
"
$(
TIMESTAMP
)
-
Script completed successfully."
>>
"
${
APT_ALL_LOG_FILE
}
"
;
fi
if
[
"
${
1
}
"
-gt
0
]
;
then
echo
-e
"
$(
TIMESTAMP
)
[X]
Script failed with error code
${
1
}
."
>>
"
${
APT_ALL_LOG_FILE
}
"
else
echo
-e
"
$(
TIMESTAMP
)
[√]
Script completed successfully."
>>
"
${
APT_ALL_LOG_FILE
}
"
;
fi
echo
-e
"-----------------------------------------------------------"
>>
"
${
APT_ALL_LOG_FILE
}
"
exit
"
${
1
}
"
}
...
...
@@ -121,7 +121,7 @@ echo -e "\n------------------------------------------------------" > ${DEST}
echo
-e
"
\n
Beginning apt-get commands on remote hosts..."
>
${
DEST
}
{
echo
-e
"
$(
TIMESTAMP
)
-
Script initiated. Will attempt upgrades for the following hosts:"
echo
-e
"
$(
TIMESTAMP
)
[√]
Script initiated. Will attempt upgrades for the following hosts:"
cat
"
${
TEMP_REM_SYS_LIST
}
"
}
>>
"
${
APT_ALL_LOG_FILE
}
"
## Log file log header.
...
...
@@ -152,7 +152,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record failure.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
RED
}
Error.
${
RESET
}
Skipping host."
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Failed ssh connection"
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[X]
Host:
${
REM_SYS
}
- Failed ssh connection"
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
## Skip to the next system in the listi (if any).
else
## Else ssh connection was successful.
{
...
...
@@ -160,7 +160,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
║
${
RESET
}
Running apt-get commands:
\t
${
BOLD
}
║
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
GREEN
}
Success.
${
RESET
}
"
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Successful ssh connection."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Successful ssh connection."
>>
"
${
APT_ALL_LOG_FILE
}
"
fi
###### Attempt update.
...
...
@@ -171,12 +171,12 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record failure.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
RED
}
Error.
${
RESET
}
Skipping..."
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Failed apt-get update."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[X]
Host:
${
REM_SYS
}
- Failed apt-get update."
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
## Skip to the next system in the list.
else
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get update
\t\t
${
GREEN
}
Success.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
GREEN
}
Success.
${
RESET
}
"
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Successful apt-get update."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Successful apt-get update."
>>
"
${
APT_ALL_LOG_FILE
}
"
fi
###### Use apt to check if any packages can be upgraded.
...
...
@@ -187,7 +187,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
BOLD
}
Up-to-date.
\t\t
${
RESET
}${
GREEN
}
Skipping...
${
RESET
}
"
;
fi
## Skip to the next remote system.
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Packages are up-to-date."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Packages are up-to-date."
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
else
## There are new packages to update.
###### Attempt dist-upgrade.
...
...
@@ -198,12 +198,12 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record failure.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
RED
}
Error.
${
RESET
}
Skipping..."
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Failed apt-get dist-upgrade."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[X]
Host:
${
REM_SYS
}
- Failed apt-get dist-upgrade."
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
## Skip to the next system in the list.
else
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get dist-upgrade
\t
${
GREEN
}
Success.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
GREEN
}
Success.
${
RESET
}
"
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Successful apt-get dist-upgrade."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Successful apt-get dist-upgrade."
>>
"
${
APT_ALL_LOG_FILE
}
"
fi
###### Attempt autoremove.
...
...
@@ -214,12 +214,12 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record failure.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
RED
}
Error.
${
RESET
}
Skipping..."
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Failed apt-get autoremove."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[X]
Host:
${
REM_SYS
}
- Failed apt-get autoremove."
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
## Skip to the next system in the list.
else
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get autoremove
\t
${
GREEN
}
Success.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
GREEN
}
Success.
${
RESET
}
"
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Successful apt-get autoremove."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Successful apt-get autoremove."
>>
"
${
APT_ALL_LOG_FILE
}
"
fi
###### Attempt autoclean.
...
...
@@ -230,7 +230,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record failure.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
RED
}
Error.
${
RESET
}
Skipping..."
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Failed apt-get autoclean."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[X]
Host:
${
REM_SYS
}
- Failed apt-get autoclean."
>>
"
${
APT_ALL_LOG_FILE
}
"
continue
## Skip to the next system in the list.
else
{
...
...
@@ -238,7 +238,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
}
>>
"
${
TEMP_SUMMARY_FILE
}
"
## Record success.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
"
${
GREEN
}
Success.
${
RESET
}
"
;
fi
echo
-e
"
$(
TIMESTAMP
)
-
Host:
${
REM_SYS
}
- Successful apt-get autoclean."
>>
"
${
APT_ALL_LOG_FILE
}
"
echo
-e
"
$(
TIMESTAMP
)
[√]
Host:
${
REM_SYS
}
- Successful apt-get autoclean."
>>
"
${
APT_ALL_LOG_FILE
}
"
fi
fi
done
2<
"
${
TEMP_REM_SYS_LIST
}
"
## File read by the while loop which includes a list of files to be backed up.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment