1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
#!/usr/bin/env python3
import os
import subprocess
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
def run_as_root(cmd_list):
"""
Verilen komut listesini pkexec ile root olarak çalıştırır.
"""
try:
subprocess.run(["pkexec"] + cmd_list, check=True)
except subprocess.CalledProcessError as e:
raise RuntimeError(f"Komut hatası: {e.cmd}, Çıkış kodu: {e.returncode}")
def get_mount_device(mount_point):
"""
/proc/mounts dosyasını okuyarak, verilen mount noktasının bağlı olduğu cihazı döner.
Args:
mount_point (str): İncelenecek mount noktası, örneğin "/media/root-ro".
Returns:
str veya None: Mount edilmiş aygıtın adı (örneğin, "/dev/sda1")
veya belirtilen mount noktası bulunamazsa None.
"""
try:
with open("/proc/mounts", "r") as f:
for line in f:
parts = line.split()
if parts[1] == mount_point:
return parts[0]
except Exception:
pass
return None
def overlay_status():
"""
/etc/overlayroot.conf dosyasını ve /media/root-rw mount noktasını kontrol eder:
- Eğer /media/root-rw mount edilmişse, overlay aktif kabul edilir.
- Aksi halde, /etc/overlayroot.conf dosyasını açar; içeriğinde "tmpfs" ifadesi varsa overlay aktif,
yoksa overlay pasif olarak belirlenir.
"""
# İlk olarak /media/root-rw mount edilip edilmediğini kontrol et
if get_mount_device("/media/root-rw"):
return True
# /etc/overlayroot.conf kontrolü
conf_path = "/etc/overlayroot.conf"
if os.path.exists(conf_path):
try:
with open(conf_path, "r") as f:
content = f.read()
return "tmpfs" in content
except Exception:
return False
else:
# Dosya yoksa paket kontrolü yapılabilir
try:
result = subprocess.run(["dpkg", "-l", "romtal-sistem-dondurma"], capture_output=True, text=True)
return "overlayroot" in result.stdout
except Exception:
return False
class OverlayrootGUI(Gtk.Window):
def __init__(self):
super().__init__(title="R.O.M.T.A.L Sistem Dondurma")
self.set_default_size(400, 250)
self.set_border_width(20)
# Stil ayarları
css = b"""
button {
font: 15px Arial;
padding: 10px;
margin: 5px;
}
"""
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
self.overlay_enabled = overlay_status()
self.create_ui()
def create_ui(self):
grid = Gtk.Grid(column_spacing=10, row_spacing=10)
self.enable_btn = Gtk.Button(label="Sistem Dondurma Aktif Et")
self.disable_btn = Gtk.Button(label="Sistem Dondurma Devre Dışı Bırak")
self.enable_btn.connect("clicked", self.enable_overlayroot)
self.disable_btn.connect("clicked", self.disable_overlayroot)
self.status_label = Gtk.Label()
self.update_status()
# Footer label ekliyoruz
self.footer_label = Gtk.Label(label="Made By R.O.M.T.A.L | https://rasimoneltml.meb.k12.tr/")
grid.attach(self.status_label, 0, 0, 2, 1)
grid.attach(self.enable_btn, 0, 1, 1, 1)
grid.attach(self.disable_btn, 1, 1, 1, 1)
grid.attach(self.footer_label, 0, 2, 2, 1)
self.add(grid)
def update_status(self):
status_text = "Şuanki Durum: " + ("Aktif" if self.overlay_enabled else "Devre Dışı")
self.status_label.set_markup(f"<b>{status_text}</b>")
self.enable_btn.set_sensitive(not self.overlay_enabled)
self.disable_btn.set_sensitive(self.overlay_enabled)
def show_dialog(self, message, is_error=False):
dialog = Gtk.MessageDialog(
parent=self,
flags=0,
message_type=Gtk.MessageType.ERROR if is_error else Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.OK,
text=message
)
dialog.run()
dialog.destroy()
def enable_overlayroot(self, widget):
try:
cmd = [
"sh", "-c",
("rm -f /etc/overlayroot.conf && "
"echo 'overlayroot_cfgdisk=\"disable\"' > /etc/overlayroot.conf && "
"echo 'overlayroot=\"tmpfs\"' >> /etc/overlayroot.conf")
]
run_as_root(cmd)
self.overlay_enabled = True
self.update_status()
self.show_dialog("Overlayroot aktif edildi!\nDeğişikliklerin geçerli olması için yeniden başlatın.")
except Exception as e:
self.show_dialog(f"Hata oluştu: {str(e)}", is_error=True)
def disable_overlayroot(self, widget):
try:
device = get_mount_device("/media/root-ro")
if not device:
raise RuntimeError("'/media/root-ro' mount edilen cihaz bulunamadı.")
cmd = [
"sh", "-c",
(f"mount -o remount,rw {device} && "
"rm -f /media/root-ro/etc/overlayroot.conf && "
"echo 'overlayroot_cfgdisk=\"disable\"' > /media/root-ro/etc/overlayroot.conf && "
"echo 'overlayroot=\"\"' >> /media/root-ro/etc/overlayroot.conf")
]
run_as_root(cmd)
self.overlay_enabled = False
self.update_status()
self.show_dialog("Overlayroot devre dışı bırakıldı!\nDeğişikliklerin geçerli olması için yeniden başlatın.")
except Exception as e:
self.show_dialog(f"Hata oluştu: {str(e)}", is_error=True)
if __name__ == "__main__":
win = OverlayrootGUI()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
|