Limpando HOME do aluno a cada inicialização: mudanças entre as edições

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Rmartins (discussão | contribs)
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...'
 
Rmartins (discussão | contribs)
Sem resumo de edição
Linha 1: Linha 1:
Deve-se editar o arquivo org.freedesktop.consolekit.policy
== Todas as versões de Ubuntu e Debian até a versão 7 ==
<code>vim /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy </syntaxhighlight>


Em seguida, modificar o arquivo do seguinte modo:.
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>


<?xml version="1.0" encoding="UTF-8"?>
== Debian 8 ==
<!DOCTYPE policyconfig PUBLIC
  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<!--
Policy definitions for ConsoleKit
-->
<policyconfig>
  <action id="org.freedesktop.consolekit.system.stop">
    <description>Stop the system</description>
    <message>System policy prevents stopping the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <!--<allow_active>auth_admin_keep</allow_active>-->
      '''<allow_active>yes</allow_active>'''
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.restart">
    <description>Restart the system</description>
    <message>System policy prevents restarting the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <!--<allow_active>auth_admin_keep</allow_active>-->
      '''<allow_active>yes</allow_active>'''
    </defaults>
  </action>
</policyconfig>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 seguinte modo:.
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


<?xml version="1.0" encoding="UTF-8"?>
[Service]
<!DOCTYPE policyconfig PUBLIC
Type=oneshot
  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
ExecStart=/etc/init.d/apagaAluno.sh
  "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
 
[Install]
<!--
WantedBy=reboot.target halt.target poweroff.target
Policy definitions for ConsoleKit
</syntaxhighlight>
-->
 
Executar os comandos:
<policyconfig>
<code>
systemctl daemon-reload
  <action id="org.freedesktop.consolekit.system.stop">
systemctl enable apagaAluno
    <description>Stop the system</description>
</syntaxhighlight>
    <message>System policy prevents stopping the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <!--<allow_active>auth_admin_keep</allow_active>-->
      '''<allow_active>yes</allow_active>'''
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.restart">
    <description>Restart the system</description>
    <message>System policy prevents restarting the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <!--<allow_active>auth_admin_keep</allow_active>-->
      '''<allow_active>yes</allow_active>'''
    </defaults>
  </action>
</policyconfig>

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:

  1. !/bin/bash
  2. 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:

  1. !/bin/bash
  2. 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>