Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scripts_shell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo E. R. Junior
scripts_shell
Commits
1ad636c1
Commit
1ad636c1
authored
8 years ago
by
Eduardo E. R. Junior
Browse files
Options
Downloads
Patches
Plain Diff
Adiciona script para mover arquivos para o directório bin
parent
86d89b29
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
move2bin
+256
-0
256 additions, 0 deletions
move2bin
with
256 additions
and
0 deletions
move2bin
0 → 100755
+
256
−
0
View file @
1ad636c1
#!/bin/bash
##======================================================================
## Eduardo Junior
## eduardo.jr@ufpr.br
## 13-11-2015
##======================================================================
## Facilitando a criacão e execução de aplicações shiny
DIR
=
`
pwd
`
SV
=
server.R
UI
=
ui.R
##======================================================================
## Funções utilizadas
_usage
()
{
cat
<<
EOF
$*
Uso: shinyApp <command> [<args>]
init: Inicia uma aplicação shiny no diretório atual
-o : inicia os arquivos shiny em uma sessão emacs e
executa a função runApp, abrindo o navegador padrão
-t : cria os arquivos com template pré-definido
run: Executa uma aplicação shiny, com função runApp
-o : inicia os arquivos shiny em uma sessão emacs e
executa a função runApp, abrindo o navegador padrão
diretório: informe o diretório da aplicação shiny
Example:
shinyApp init
shinyApp init -t
shinyApp init -o -t
shinyApp init -to
shinyApp run -o
shinyApp run ~/path -o
EOF
}
build_App
()
{
if
[
-e
"
$SV
"
]
||
[
-e
"
$UI
"
]
;
then
echo
"O diretório já contém arquivos ui.R e/ou server.R"
echo
-n
" Deseja sobrescrever? "
read
ANSWER
case
"
$ANSWER
"
in
s
|
sim
|
y
|
yes
)
echo
""
;;
n
|
não
|
no
)
exit
1
;;
*
)
echo
" Responda com as palavres: yes ou no"
exit
1
esac
fi
##-------------------------------------------
# Criando o server.R
echo
"##-------------------------------------------"
>
server.R
echo
"## server.R"
>>
server.R
echo
""
>>
server.R
echo
"library(shiny)"
>>
server.R
echo
""
>>
server.R
echo
"shinyServer("
>>
server.R
echo
" function(input, output, session) {"
>>
server.R
echo
" "
>>
server.R
echo
" }"
>>
server.R
echo
")"
>>
server.R
##-------------------------------------------
# Criando o ui.R
echo
"##-------------------------------------------"
>
ui.R
echo
"## ui.R"
>>
ui.R
echo
""
>>
ui.R
echo
"library(shiny)"
>>
ui.R
echo
""
>>
ui.R
echo
"shinyUI("
>>
ui.R
echo
" fluidPage("
>>
ui.R
echo
" "
>>
ui.R
echo
" )"
>>
ui.R
echo
")"
>>
ui.R
##-------------------------------------------
# Verificando a execução
case
$1
in
run
)
echo
"Criando ui.R e server.R em
$DIR
"
emacs server.R ui.R &
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
;;
*
)
echo
"Arquivos criados em
$DIR
"
esac
}
build_AppTemplate
()
{
if
[
-e
"
$SV
"
]
||
[
-e
"
$UI
"
]
;
then
echo
"O diretório já contém arquivos ui.R e/ou server.R"
echo
-n
" Deseja sobrescrever? "
read
ANSWER
case
"
$ANSWER
"
in
s
|
sim
|
y
|
yes
)
echo
""
;;
n
|
não
|
no
)
exit
1
;;
*
)
echo
" Responda com as palavres: yes ou no"
exit
1
esac
fi
##-------------------------------------------
# Criando o server.R
echo
"##-------------------------------------------"
>
server.R
echo
"## server.R"
>>
server.R
echo
""
>>
server.R
echo
"library(shiny)"
>>
server.R
echo
""
>>
server.R
echo
""
echo
"shinyServer("
>>
server.R
echo
" function(input, output, session) {"
>>
server.R
echo
" "
>>
server.R
echo
" }"
>>
server.R
echo
")"
>>
server.R
##-------------------------------------------
# Criando o ui.R
echo
"##-------------------------------------------"
>
ui.R
echo
"## ui.R"
>>
ui.R
echo
""
>>
ui.R
echo
"library(shiny)"
>>
ui.R
echo
""
>>
ui.R
echo
"shinyUI("
>>
ui.R
echo
" fluidPage("
>>
ui.R
echo
" h1(
\"
Título
\"
,"
>>
ui.R
echo
" style =
\"
font-family: 'Ubuntu Light';"
>>
ui.R
echo
" color: #fff; text-align: center;"
>>
ui.R
echo
" background-color: #C8C8C8;"
>>
ui.R
echo
" padding: 20px; font-weight: bold;
\"
)"
>>
ui.R
echo
" "
>>
ui.R
echo
" )"
>>
ui.R
echo
")"
>>
ui.R
##-------------------------------------------
# Verificando a execução
case
$1
in
run
)
echo
"Criando ui.R e server.R em
$DIR
"
emacs server.R ui.R &
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
;;
*
)
echo
"Arquivos criados em
$DIR
"
esac
}
echo
"-------------------------------------------"
## Verificando quantidade de argumentos:
if
[
$#
-eq
0
]
||
[
$#
-gt
3
]
;
then
echo
"Número de argumentos incorreto! Consulte shinyApp --help"
exit
1
fi
# Daria para usar `getopts` se não houvesse a necessidade de dois comandos
# secundários, init e run. getopts é MUITO MUItO útil para opções do
# tipo -*
##======================================================================
## Inicia o script
if
[
$1
=
"init"
]
;
then
if
[
$#
-eq
1
]
;
then
build_App
elif
[
$#
-eq
2
]
;
then
case
$2
in
-h
|
--help
)
_usage
;;
-o
)
build_App run
;;
-t
)
build_AppTemplate
;;
-ot
|
-to
)
build_AppTemplate run
;;
*
)
echo
"Argumentos incorretos! Consulte shinyApp --help"
exit
1
esac
elif
[
$#
-eq
3
]
;
then
if
([
$2
=
"-t"
]
&&
[
$3
=
"-o"
])
||
([
$2
=
"-o"
]
&&
[
$3
=
"-t"
])
;
then
build_AppTemplate run
else
echo
"Argumentos inválidos! Consulte shinyApp --help"
exit
1
fi
fi
elif
[
$1
=
"run"
]
;
then
if
[
$#
-eq
1
]
;
then
echo
"Executando a aplicação em
$DIR
"
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
elif
[
$#
-eq
2
]
;
then
case
$2
in
-h
|
--help
)
_usage
;;
-o
)
echo
"Executando a aplicação e abrir arquivos no emacs"
emacs server.R ui.R &
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
;;
*
)
if
[
-d
$2
]
;
then
cd
$2
if
[
!
-e
"
$SV
"
]
||
[
!
-e
"
$UI
"
]
;
then
echo
"Este diretório não contém uma aplicação shiny completa"
echo
"Verifique os arquivos server.R e ui.R em
$2
"
exit
1
fi
echo
"Executando a aplicação em
$2
"
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
else
echo
"Argumentos inválidos! Consulte shinyApp --help"
exit
1
fi
esac
elif
[
$#
-eq
3
]
;
then
if
[
$2
=
"-o"
]
&&
[
-d
$3
]
;
then
echo
"Executando a aplicação em
$3
"
cd
$3
if
[
!
-e
"
$SV
"
]
||
[
!
-e
"
$UI
"
]
;
then
echo
"Este diretório não contém uma aplicação shiny completa"
echo
"Verifique os arquivos server.R e ui.R em
$3
"
exit
1
fi
emacs server.R ui.R &
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
elif
[
-d
$2
]
&&
[
$3
=
"-o"
]
;
then
echo
"Executando a aplicação em
$2
"
cd
$2
if
[
!
-e
"
$SV
"
]
||
[
!
-e
"
$UI
"
]
;
then
echo
"Este diretório não contém uma aplicação shiny completa"
echo
"Verifique os arquivos server.R e ui.R em
$2
"
exit
1
fi
emacs server.R ui.R &
echo
"Pressione ^C para interromper a aplicação"
Rscript
-e
"shiny::runApp(getwd(), launch.browser = TRUE)"
else
echo
"Argumentos inválidos! Consulte shinyApp --help"
exit
1
fi
fi
elif
[
$1
=
"-h"
]
||
[
$1
=
"--help"
]
;
then
_usage
else
echo
"Argumentos inválidos! Consulte shinyApp --help"
fi
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