Limpando HOME do aluno a cada inicialização: mudanças entre as edições
Criou página com 'Deve-se editar o arquivo org.freedesktop.consolekit.policy <code>vim /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy </syntaxhighlight> Em seguida, modificar o arquivo do se...' |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
== Todas as versões de Ubuntu e Debian até a versão 7 == | |||
Criar um arquivo, irei adotar como exemplo o /etc/init.d/apagaAluno.sh, como dono e grupo o "root" e com permissão "755" com o seguinte conteúdo: | |||
<code> | |||
#!/bin/bash | |||
#Restaurar o usuario aluno a cada inicializacao. | |||
rm -rf /var/spool/cron/crontabs/aluno | |||
rm -rf /home/aluno | |||
tar -zxvf /home/backup/aluno.tgz -C / | |||
</syntaxhighlight> | |||
Para o próximo passo é possível fazer de 2 modos: | |||
===Modo 1=== | |||
Executar o comando: | |||
<code> update-rc.d apagaAluno start 0 6 /etc/init.d/apagaAluno.sh</syntaxhighlight> | |||
===Modo 2=== | |||
Executar os comandos: | |||
<code> | |||
ln -s /etc/init.d/apagaAluno.sh /etc/rc0.d/K30apagaAluno | |||
ln -s /etc/init.d/apagaAluno.sh /etc/rc6.d/K30apagaAluno | |||
</syntaxhighlight> | |||
== Debian 8 == | |||
Criar um arquivo, irei adotar como exemplo o /etc/init.d/apagaAluno.sh, como dono e grupo o "root" e com permissão "755" com o seguinte conteúdo: | |||
<code> | |||
#!/bin/bash | |||
#Restaurar o usuario aluno a cada inicializacao. | |||
rm -rf /var/spool/cron/crontabs/aluno | |||
rm -rf /home/aluno | |||
tar -zxvf /home/backup/aluno.tgz -C / | |||
</syntaxhighlight> | |||
Criar outro arquivo em "/lib/systemd/system" com o nome '''apagaAluno.service''': | |||
<code> | |||
[Unit] | |||
Description=Usuário padrão | |||
DefaultDependencies=no | |||
Before=shutdown.target | |||
[Service] | |||
Type=oneshot | |||
ExecStart=/etc/init.d/apagaAluno.sh | |||
[Install] | |||
WantedBy=reboot.target halt.target poweroff.target | |||
</syntaxhighlight> | |||
Executar os comandos: | |||
<code> | |||
systemctl daemon-reload | |||
systemctl enable apagaAluno | |||
</syntaxhighlight> | |||
Edição das 17h28min de 4 de novembro de 2015
1 Todas as versões de Ubuntu e Debian até a versão 7
Criar um arquivo, irei adotar como exemplo o /etc/init.d/apagaAluno.sh, como dono e grupo o "root" e com permissão "755" com o seguinte conteúdo:
- !/bin/bash
- Restaurar o usuario aluno a cada inicializacao.
rm -rf /var/spool/cron/crontabs/aluno
rm -rf /home/aluno
tar -zxvf /home/backup/aluno.tgz -C /
</syntaxhighlight>
Para o próximo passo é possível fazer de 2 modos:
1.1 Modo 1
Executar o comando:
update-rc.d apagaAluno start 0 6 /etc/init.d/apagaAluno.sh</syntaxhighlight>
1.2 Modo 2
Executar os comandos:
ln -s /etc/init.d/apagaAluno.sh /etc/rc0.d/K30apagaAluno
ln -s /etc/init.d/apagaAluno.sh /etc/rc6.d/K30apagaAluno
</syntaxhighlight>
2 Debian 8
Criar um arquivo, irei adotar como exemplo o /etc/init.d/apagaAluno.sh, como dono e grupo o "root" e com permissão "755" com o seguinte conteúdo:
- !/bin/bash
- Restaurar o usuario aluno a cada inicializacao.
rm -rf /var/spool/cron/crontabs/aluno
rm -rf /home/aluno
tar -zxvf /home/backup/aluno.tgz -C /
</syntaxhighlight>
Criar outro arquivo em "/lib/systemd/system" com o nome apagaAluno.service:
[Unit]
Description=Usuário padrão
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/etc/init.d/apagaAluno.sh
[Install]
WantedBy=reboot.target halt.target poweroff.target
</syntaxhighlight>
Executar os comandos:
systemctl daemon-reload
systemctl enable apagaAluno
</syntaxhighlight>