Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linuxconf
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
linuxconf
Commits
6435fe9d
There was an error fetching the commit references. Please try again later.
Commit
6435fe9d
authored
1 month ago
by
Recolic
Browse files
Options
Downloads
Patches
Plain Diff
.builtin: bgrun
parent
8aacd3ef
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
linuxconf
+19
-0
19 additions, 0 deletions
linuxconf
with
19 additions
and
0 deletions
linuxconf
+
19
−
0
View file @
6435fe9d
#!/bin/bash
#!/bin/bash
# Useful functions as built-in
function
echo2
()
{
function
echo2
()
{
echo
"
$@
"
1>&2
echo
"
$@
"
1>&2
}
}
...
@@ -11,6 +12,24 @@ function die () {
...
@@ -11,6 +12,24 @@ function die () {
err
"
$@
"
err
"
$@
"
exit
1
exit
1
}
}
function
bgrun
()
{
# Usage: bgrun /var/log/your.log sslocal -s xxx -p 'hello world my password' -l xxx --xxx
# Usage: bgrun /var/log/your.log auto_restart frpc -c my_server.ini
# v202504-1
local
logF
=
"
$1
"
shift
local
cmd
=
"
$1
"
shift
if
[
"
$cmd
"
=
auto_restart
]
&&
[
!
-f
/tmp/.auto_restart
]
;
then
echo
IyEvYmluL2Jhc2gKCndoaWxlIHRydWU7IGRvCiAgICAiJEAiCiAgICBbWyAkPyA9IDEzMCBdXSAmJiBicmVhawogICAgc2xlZXAgMQpkb25lCg
==
|
base64
-d
>
/tmp/.auto_restart
chmod
ugo+rx /tmp/.auto_restart
cmd
=
/tmp/.auto_restart
fi
echo
"[
$(
date
--utc
)
] EXEC
$cmd
$@
"
>>
"
$logF
"
nohup
"
$cmd
"
"
$@
"
>>
"
$logF
"
2>&1 &
disown
return
$?
}
function
lc_assert_user_is
()
{
function
lc_assert_user_is
()
{
[[
"
$(
whoami
)
"
=
"
$1
"
]]
||
exit
0
[[
"
$(
whoami
)
"
=
"
$1
"
]]
||
exit
0
...
...
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